if (tps != null) tps.stop(); tps = new TPS (cfg.getBoolean ("auto-update-tps", true)); for (int i=0; i<sessions; i++) { new Thread(this).start();
public void run() { TPS tps = new TPS(); try (BinLogWriter bl = new BinLogWriter(dir)) { for (int i = 1; i <= 10000; i++) { long l = cnt.incrementAndGet(); if (i % 5000 == 0) { bl.cutover(); } bl.add(ISOUtil.zeropad(l, 12).getBytes()); tps.tick(); } tps.dump(System.out, ""); } catch (Throwable e) { e.printStackTrace(System.err); } }
public void test1000TPSManualUpdate() throws Exception { TPS tps = new TPS(); for (int i=0; i<1000; i++) tps.tick(); Thread.sleep (1050L); assertTrue("Expected aprox 1000 TPS but was "+ tps.intValue(), tps.intValue() >= 900); assertTrue("Still expecting aprox 1000 TPS on a second call", tps.intValue() >= 900); Thread.sleep (1050L); assertEquals( "TPS should be zero but it's "+tps.intValue() + " (" + tps.floatValue() + ")", 0, tps.intValue() ); } }
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 = new TPS(true); for (int i=0; i<COUNT; i++) { unpack (buf, p); tps = new TPS(true); for (int i=0; i<COUNT; i++) { pack (baseMsg, p); tps = new TPS(true); for (int i=0; i<COUNT; i++) { updatePackAndUnpack(baseMsg, p);
public void test1000TPSAutoUpdate() throws Exception { TPS tps = new TPS(true); for (int i=0; i<1000; i++) tps.tick(); Thread.sleep (1050L); // java.util.Timer is not accurate assertEquals("Expected 1000 TPS", 1000, tps.intValue()); assertEquals("Still expecting 1000 TPS on a second call", 1000, tps.intValue()); Thread.sleep (1000L); assertTrue ("Average should be aprox 0.5 but it's " + tps.getAvg(), tps.getAvg() >= 0.5); assertEquals( "TPS should be zero but it's "+tps.intValue() + " (" + tps.floatValue() + ")", 0, tps.intValue() ); assertEquals ("Peak has to be 1000", 1000, tps.getPeak()); tps.stop(); } public void test1000TPSManualUpdate() throws Exception {