Search in sources :

Example 1 with Payload

use of com.oracle.truffle.tools.profiler.CPUSampler.Payload in project graal by oracle.

the class CPUSamplerTest method searchInitializeContext.

private static List<ProfilerNode<Payload>> searchInitializeContext(Map<TruffleContext, CPUSamplerData> data) {
    List<ProfilerNode<Payload>> found = new ArrayList<>();
    for (CPUSamplerData d : data.values()) {
        Map<Thread, Collection<ProfilerNode<Payload>>> threadData = d.getThreadData();
        assertEquals(threadData.toString(), 1, threadData.size());
        searchNodes(found, threadData.values().iterator().next(), (node) -> {
            return node.getRootName().equals("<<" + ProxyLanguage.ID + ":initializeContext>>");
        });
    }
    return found;
}
Also used : CPUSamplerData(com.oracle.truffle.tools.profiler.CPUSamplerData) ProfilerNode(com.oracle.truffle.tools.profiler.ProfilerNode) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Payload(com.oracle.truffle.tools.profiler.CPUSampler.Payload)

Example 2 with Payload

use of com.oracle.truffle.tools.profiler.CPUSampler.Payload in project graal by oracle.

the class CPUSamplerTest method testTiers.

@Test
public void testTiers() {
    Assume.assumeFalse(Truffle.getRuntime().getClass().toString().contains("Default"));
    Context.Builder builder = Context.newBuilder().option("engine.FirstTierCompilationThreshold", Integer.toString(FIRST_TIER_THRESHOLD)).option("engine.LastTierCompilationThreshold", Integer.toString(2 * FIRST_TIER_THRESHOLD)).option("engine.BackgroundCompilation", "false");
    Map<TruffleContext, CPUSamplerData> data;
    try (Context c = builder.build()) {
        CPUSampler cpuSampler = CPUSampler.find(c.getEngine());
        cpuSampler.setCollecting(true);
        for (int i = 0; i < 3 * FIRST_TIER_THRESHOLD; i++) {
            c.eval(defaultSourceForSampling);
        }
        data = cpuSampler.getData();
    }
    CPUSamplerData samplerData = data.values().iterator().next();
    Collection<ProfilerNode<CPUSampler.Payload>> profilerNodes = samplerData.getThreadData().values().iterator().next();
    ProfilerNode<CPUSampler.Payload> root = profilerNodes.iterator().next();
    for (ProfilerNode<CPUSampler.Payload> child : root.getChildren()) {
        CPUSampler.Payload payload = child.getPayload();
        int numberOfTiers = payload.getNumberOfTiers();
        Assert.assertEquals(3, numberOfTiers);
        for (int i = 0; i < numberOfTiers; i++) {
            Assert.assertTrue(payload.getTierTotalCount(i) >= 0);
            Assert.assertTrue(payload.getTierSelfCount(i) >= 0);
        }
    }
}
Also used : TruffleContext(com.oracle.truffle.api.TruffleContext) Context(org.graalvm.polyglot.Context) CPUSamplerData(com.oracle.truffle.tools.profiler.CPUSamplerData) ProfilerNode(com.oracle.truffle.tools.profiler.ProfilerNode) TruffleContext(com.oracle.truffle.api.TruffleContext) Payload(com.oracle.truffle.tools.profiler.CPUSampler.Payload) Payload(com.oracle.truffle.tools.profiler.CPUSampler.Payload) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint) CPUSampler(com.oracle.truffle.tools.profiler.CPUSampler) Test(org.junit.Test)

Example 3 with Payload

use of com.oracle.truffle.tools.profiler.CPUSampler.Payload in project graal by oracle.

the class CPUSamplerTest method testCorrectRootStructure.

@Test
public void testCorrectRootStructure() {
    sampler.setFilter(NO_INTERNAL_ROOT_TAG_FILTER);
    sampler.setCollecting(true);
    for (int i = 0; i < executionCount; i++) {
        eval(defaultSourceForSampling);
    }
    Collection<ProfilerNode<Payload>> children = getProfilerNodes();
    Assert.assertEquals(1, children.size());
    ProfilerNode<CPUSampler.Payload> program = children.iterator().next();
    Assert.assertEquals("", program.getRootName());
    checkTimeline(program.getPayload());
    children = program.getChildren();
    Assert.assertEquals(2, children.size());
    Iterator<ProfilerNode<CPUSampler.Payload>> iterator = children.iterator();
    ProfilerNode<CPUSampler.Payload> baz = iterator.next();
    if (!"baz".equals(baz.getRootName())) {
        baz = iterator.next();
    }
    Assert.assertEquals("baz", baz.getRootName());
    checkTimeline(baz.getPayload());
    children = baz.getChildren();
    Assert.assertEquals(1, children.size());
    ProfilerNode<CPUSampler.Payload> bar = children.iterator().next();
    Assert.assertEquals("bar", bar.getRootName());
    checkTimeline(bar.getPayload());
    children = bar.getChildren();
    Assert.assertEquals(1, children.size());
    ProfilerNode<CPUSampler.Payload> foo = children.iterator().next();
    Assert.assertEquals("foo", foo.getRootName());
    checkTimeline(foo.getPayload());
    children = foo.getChildren();
    Assert.assertTrue(children.size() == 0);
}
Also used : ProfilerNode(com.oracle.truffle.tools.profiler.ProfilerNode) Payload(com.oracle.truffle.tools.profiler.CPUSampler.Payload) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint) CPUSampler(com.oracle.truffle.tools.profiler.CPUSampler) Test(org.junit.Test)

Aggregations

Payload (com.oracle.truffle.tools.profiler.CPUSampler.Payload)3 ProfilerNode (com.oracle.truffle.tools.profiler.ProfilerNode)3 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)2 CPUSampler (com.oracle.truffle.tools.profiler.CPUSampler)2 CPUSamplerData (com.oracle.truffle.tools.profiler.CPUSamplerData)2 Test (org.junit.Test)2 TruffleContext (com.oracle.truffle.api.TruffleContext)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Context (org.graalvm.polyglot.Context)1