use of org.spf4j.stackmonitor.Sampler in project spf4j by zolyfarkas.
the class LifoThreadPoolExecutorCoreIdlingTest method testLifoExecSQ.
@Test(timeout = 60000)
public void testLifoExecSQ() throws InterruptedException, IOException {
LifoThreadPoolExecutorSQP executor = new LifoThreadPoolExecutorSQP("test", 2, 8, 20, 0);
File destFolder = new File(org.spf4j.base.Runtime.TMP_FOLDER);
Sampler s = Sampler.getSampler(20, 10000, destFolder, "lifeTest1");
s.start();
org.spf4j.base.Runtime.gc(5000);
Thread.sleep(100);
long time = CpuUsageSampler.getProcessCpuTimeNanos();
Thread.sleep(3000);
long cpuTime = CpuUsageSampler.getProcessCpuTimeNanos() - time;
File dumpToFile = s.dumpToFile();
Assert.assertEquals(destFolder.getCanonicalFile(), dumpToFile.getParentFile().getCanonicalFile());
LOG.info("Cpu profile saved to {}", dumpToFile);
LOG.debug("CPU time = {} ns", cpuTime);
s.stop();
Assert.assertTrue("CPU Time = " + cpuTime, cpuTime < 1500000000);
// 6069497000 with bug 53945000/8035000/6000000 without bug without profiler, 119628000 with profiler
executor.shutdown();
executor.awaitTermination(1, TimeUnit.SECONDS);
}
Aggregations