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;
}
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);
}
}
}
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);
}
Aggregations