Search in sources :

Example 1 with Profiler

use of org.jpos.util.Profiler in project jPOS by jpos.

the class JDBMSpaceTestCase method testNoAutoCommit.

@Test
public void testNoAutoCommit() throws Exception {
    String s = "The quick brown fox jumped over the lazy dog";
    Profiler prof = new Profiler();
    synchronized (sp) {
        sp.setAutoCommit(false);
        for (int i = 0; i < COUNT; i++) {
            sp.out("testNoAutoCommit_Key" + Integer.toString(i), s);
            if (i % 100 == 0)
                prof.checkPoint("out " + i);
        }
        prof.checkPoint("pre-commit");
        sp.commit();
        sp.setAutoCommit(true);
        prof.checkPoint("commit");
    }
    // prof.dump (System.err, "NoAutoCommit out >");
    prof = new Profiler();
    synchronized (sp) {
        sp.setAutoCommit(false);
        for (int i = 0; i < COUNT; i++) {
            assertTrue(s.equals(sp.in("testNoAutoCommit_Key" + Integer.toString(i))));
            if (i % 100 == 0)
                prof.checkPoint("in " + i);
        }
        prof.checkPoint("pre-commit");
        sp.commit();
        sp.setAutoCommit(true);
        prof.checkPoint("commit");
    }
// prof.dump (System.err, "NoAutoCommit in  >");
}
Also used : Profiler(org.jpos.util.Profiler) Test(org.junit.jupiter.api.Test)

Example 2 with Profiler

use of org.jpos.util.Profiler in project jPOS by jpos.

the class TSpaceTestCase method testMultiKeyLoad.

@Test
public void testMultiKeyLoad() throws Exception {
    String s = "The quick brown fox jumped over the lazy dog";
    Profiler prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        sp.out("testMultiKeyLoad_Key" + Integer.toString(i), s, 60000);
    }
    // prof.dump (System.err, "MultiKeyLoad out >");
    prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        assertTrue(s.equals(sp.in("testMultiKeyLoad_Key" + Integer.toString(i))));
    }
// prof.dump (System.err, "MultiKeyLoad in  >");
}
Also used : Profiler(org.jpos.util.Profiler) Test(org.junit.jupiter.api.Test)

Example 3 with Profiler

use of org.jpos.util.Profiler in project jPOS by jpos.

the class TSpaceTestCase method testSingleKeyLoad.

@Test
public void testSingleKeyLoad() throws Exception {
    String s = "The quick brown fox jumped over the lazy dog";
    String k = "testSingleKeyLoad_SingleKey";
    Profiler prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        sp.out(k, s, 60000);
    }
    // prof.dump (System.err, "SingleKeyLoad out >");
    prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        assertTrue(s.equals(sp.in(k)));
    }
    // prof.dump (System.err, "SingleKeyLoad in  >");
    assertNull(sp.rdp(k));
}
Also used : Profiler(org.jpos.util.Profiler) Test(org.junit.jupiter.api.Test)

Example 4 with Profiler

use of org.jpos.util.Profiler in project jPOS by jpos.

the class LOGGER_BENCHMARK method exec.

public void exec(CLIContext ctx, String[] args) throws Exception {
    if (args.length != 3) {
        ctx.println(String.format("Usage: %s threads messages", args[0]));
        return;
    }
    int threadCount = Integer.parseInt(args[1]);
    final int numMessages = Integer.parseInt(args[2]);
    final Profiler p = new Profiler();
    final CountDownLatch done = new CountDownLatch(threadCount);
    for (int i = 0; i < threadCount; i++) {
        final String name = "Thread " + i;
        new Thread() {

            public void run() {
                for (int i = 0; i < numMessages; i++) {
                    LogEvent ev = new LogEvent();
                    ev.addMessage(name + " " + i);
                    Logger.log(ev);
                }
                p.checkPoint(name);
                done.countDown();
            }
        }.start();
    }
    done.await();
    p.dump(System.out, "");
}
Also used : Profiler(org.jpos.util.Profiler) LogEvent(org.jpos.util.LogEvent) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 5 with Profiler

use of org.jpos.util.Profiler in project jPOS by jpos.

the class JDBMSpaceTestCase method testMultiKeyLoad.

@Test
public void testMultiKeyLoad() throws Exception {
    String s = "The quick brown fox jumped over the lazy dog";
    Profiler prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        sp.out("testMultiKeyLoad_Key" + Integer.toString(i), s);
        if (i % 100 == 0)
            prof.checkPoint("out " + i);
    }
    // prof.dump (System.err, "MultiKeyLoad out >");
    prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        assertTrue(s.equals(sp.in("testMultiKeyLoad_Key" + Integer.toString(i))));
        if (i % 100 == 0)
            prof.checkPoint("in " + i);
    }
// prof.dump (System.err, "MultiKeyLoad in  >");
}
Also used : Profiler(org.jpos.util.Profiler) Test(org.junit.jupiter.api.Test)

Aggregations

Profiler (org.jpos.util.Profiler)9 Test (org.junit.jupiter.api.Test)8 CountDownLatch (java.util.concurrent.CountDownLatch)1 ISOMsg (org.jpos.iso.ISOMsg)1 ISOPackager (org.jpos.iso.ISOPackager)1 LogEvent (org.jpos.util.LogEvent)1 TPS (org.jpos.util.TPS)1