use of com.oracle.truffle.tools.profiler.StackTraceEntry in project graal by oracle.
the class ManualSamplingTest method assertEntry.
private static void assertEntry(Iterator<StackTraceEntry> iterator, String expectedName, int expectedCharIndex) {
StackTraceEntry entry = iterator.next();
assertEquals(expectedName, entry.getRootName());
assertEquals(expectedCharIndex, entry.getSourceSection().getCharIndex());
assertNotNull(entry.toStackTraceElement());
assertNotNull(entry.toString());
assertNotNull(entry.hashCode());
assertTrue(entry.equals(entry));
}
use of com.oracle.truffle.tools.profiler.StackTraceEntry in project graal by oracle.
the class NoTagSamplingTest method testNoTagSampling.
@Test
public void testNoTagSampling() throws InterruptedException, ExecutionException {
ExecutorService singleThread = Executors.newSingleThreadExecutor();
await = new Semaphore(0);
try (Context context = Context.create(NoTagLanguage.ID)) {
CPUSampler sampler = CPUSampler.find(context.getEngine());
Source source = Source.newBuilder(NoTagLanguage.ID, "", "").buildLiteral();
Future<?> f = singleThread.submit(() -> {
return context.eval(source).asInt();
});
Map<Thread, List<StackTraceEntry>> sample = null;
for (int i = 0; i < 10000; i++) {
// times out after 10s
sample = sampler.takeSample();
if (!sample.isEmpty()) {
break;
}
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new AssertionError(e);
}
}
// wait for future
await.release();
assertEquals(42, f.get());
assertTrue(!sample.isEmpty());
List<StackTraceEntry> entries = sample.values().iterator().next();
assertEquals(1, entries.size());
assertEquals(TEST_ROOT_NAME, entries.get(0).getRootName());
singleThread.shutdown();
singleThread.awaitTermination(10, TimeUnit.SECONDS);
}
}
Aggregations