Search in sources :

Example 6 with Profiler

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

the class JESpaceTestCase method testMultiKeyLoad.

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)

Example 7 with Profiler

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

the class JESpaceTestCase method testSingleKeyLoad.

public void testSingleKeyLoad() throws Exception {
    String s = "The quick brown fox jumped over the lazy dog";
    String k = "testSingleKeyLoad_Key";
    Profiler prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        sp.out(k, s);
        if (i % 100 == 0)
            prof.checkPoint("out " + i);
    }
    // prof.dump (System.err, "SingleKeyLoad out >");
    prof = new Profiler();
    for (int i = 0; i < COUNT; i++) {
        assertTrue(s.equals(sp.in(k)));
        if (i % 100 == 0)
            prof.checkPoint("in " + i);
    }
    // prof.dump (System.err, "SingleKeyLoad in  >");
    assertTrue(sp.rdp(k) == null);
}
Also used : Profiler(org.jpos.util.Profiler)

Example 8 with Profiler

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

the class PackagerTestCase method testPerformance.

public void testPerformance() throws Exception {
    final int COUNT = 100000;
    ISOPackager p = new GenericPackager("src/main/resources/packager/iso87binary.xml");
    ISOMsg baseMsg = getMsg("ISO87");
    System.out.println("\n--- pack/unpack performance test ---\n");
    Profiler prof = new Profiler();
    TPS tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        pack(baseMsg, p);
        tps.tick();
    }
    prof.checkPoint("PACK " + tps.toString());
    byte[] buf = baseMsg.pack();
    tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        unpack(buf, p);
        tps.tick();
    }
    prof.checkPoint("UNPACK " + tps.toString());
    tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        pack(baseMsg, p);
        unpack(buf, p);
        tps.tick();
    }
    prof.checkPoint("PACK/UNPACK " + tps.toString());
    tps = new TPS(true);
    for (int i = 0; i < COUNT; i++) {
        updatePackAndUnpack(baseMsg, p);
        tps.tick();
    }
    prof.checkPoint("UPDATE/PACK/UNPACK " + tps.toString());
    prof.dump(System.out, "");
    System.out.println("");
}
Also used : ISOPackager(org.jpos.iso.ISOPackager) ISOMsg(org.jpos.iso.ISOMsg) Profiler(org.jpos.util.Profiler) TPS(org.jpos.util.TPS)

Example 9 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)

Aggregations

Profiler (org.jpos.util.Profiler)9 Test (org.junit.Test)2 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