Search in sources :

Example 6 with Sampler

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);
}
Also used : CpuUsageSampler(org.spf4j.perf.cpu.CpuUsageSampler) Sampler(org.spf4j.stackmonitor.Sampler) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)6 Sampler (org.spf4j.stackmonitor.Sampler)6 Test (org.junit.Test)5 CpuUsageSampler (org.spf4j.perf.cpu.CpuUsageSampler)4 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 Server (org.h2.tools.Server)1 Ignore (org.junit.Ignore)1