public void actionPerformed(ActionEvent e) { TPS t = txnmgr.getTPS(); tps.setText (Integer.toString (t.intValue())); tpsAvg.setText (String.format ("%.2f", t.getAvg())); tpsPeak.setText (Integer.toString (t.getPeak())); }
public String toString() { return String.format("tps=%d, peak=%d, avg=%.2f", intValue(), getPeak(), getAvg()); }
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() ); } }
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 {