Search in sources :

Example 1 with TimerKey

use of org.graalvm.compiler.debug.TimerKey in project graal by oracle.

the class TimerKeyTest method test2.

/**
 * Asserts that a timer replied recursively without any other interleaving timers has the same
 * flat and accumulated times.
 */
@Test
public void test2() {
    EconomicMap<OptionKey<?>, Object> map = EconomicMap.create();
    map.put(DebugOptions.Time, "");
    OptionValues options = new OptionValues(map);
    DebugContext debug = DebugContext.create(options, NO_DESCRIPTION, NO_GLOBAL_METRIC_VALUES, DEFAULT_LOG_STREAM, NO_CONFIG_CUSTOMIZERS);
    TimerKey timerC = DebugContext.timer("TimerC");
    try (DebugCloseable c1 = timerC.start(debug)) {
        spin(50);
        try (DebugCloseable c2 = timerC.start(debug)) {
            spin(50);
            try (DebugCloseable c3 = timerC.start(debug)) {
                spin(50);
                try (DebugCloseable c4 = timerC.start(debug)) {
                    spin(50);
                    try (DebugCloseable c5 = timerC.start(debug)) {
                        spin(50);
                    }
                }
            }
        }
    }
    if (timerC.getFlat() != null) {
        assertEquals(timerC.getFlat().getCurrentValue(debug), timerC.getCurrentValue(debug));
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) OptionKey(org.graalvm.compiler.options.OptionKey) DebugContext(org.graalvm.compiler.debug.DebugContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) TimerKey(org.graalvm.compiler.debug.TimerKey) Test(org.junit.Test)

Aggregations

DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 TimerKey (org.graalvm.compiler.debug.TimerKey)1 OptionKey (org.graalvm.compiler.options.OptionKey)1 OptionValues (org.graalvm.compiler.options.OptionValues)1 Test (org.junit.Test)1