public void startOperation() { t.reset(); } public void endOperation() {
private void feedData() { boolean batchDone = false; int throttledOpsPerSec = DataFeedPrms.getThrottledOpsPerSec(); if (throttledOpsPerSec > 0) { do { this.timer.reset(); for (int i = 0; i < throttledOpsPerSec; i++) { batchDone = feed(); } long remaining = 1000000000 - this.timer.reset(); if (remaining > 0) { MasterController.sleepForMs((int)(remaining/1000000d)); } } while (!batchDone); } else { do { batchDone = feed(); } while (!batchDone); } } private boolean feed() {
private void cycleCQs() { boolean batchDone = false; int throttledOpsPerSec = CQPrms.getThrottledOpsPerSec(); CqQuery[] cqs = (CqQuery[])localcqs.get(); if (throttledOpsPerSec > 0) { do { this.timer.reset(); for (int i = 0; i < throttledOpsPerSec; i++) { batchDone = cycleCQ(cqs[i%cqs.length]); } long remaining = 1000000000 - this.timer.reset(); if (remaining > 0) { MasterController.sleepForMs((int)(remaining/1000000d)); } } while (!batchDone); } else { int i = 0; do { batchDone = cycleCQ(cqs[i%cqs.length]); ++i; } while (!batchDone); } }
public void endOperation() { statistics().incLong( OPS, 1 ); statistics().incLong( OP_TIME, t.reset() ); } }
/** * A hydra TASK that populates the remote queue */ public static void populate() throws RemoteException, InterruptedException { RemoteBlockingQueue queue = getQueue(); NanoTimer timer = new NanoTimer(); for (int i = 0; i < 500; i++) { QueueElement element = new QueueElement(); if (RBQPrms.debug()) { Log.getLogWriter().info("Offering " + element); } timer.reset(); queue.offer(element, Integer.MAX_VALUE, TimeUnit.SECONDS); long duration = timer.reset(); if (RBQPrms.useBlackboard()) { RBQBlackboard.getBB().noteOffer(duration); } } }
/** Do a get in order to try to bring in entries from other distributed * caches. This get may or may not actually bring in a new entry. */ protected void randomGet() { Region workRegion = getWorkRegion(); Object key = getPreviousKey(); String aStr = key + " in " + TestHelper.regionToString(workRegion, false); Log.getLogWriter().info("Getting previous key " + aStr + " with callback object " + this); try { nt.reset(); workRegion.get(key, this); long duration = nt.reset(); Log.getLogWriter().info("Done getting " + aStr + "; get took " + TestHelper.nanosToString(duration)); } catch (TimeoutException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (CacheLoaderException e) { throw new TestException(TestHelper.getStackTrace(e)); } }
return (timer.reset());
Log.getLogWriter().info("Getting " + aStr + " with callback object " + this); try { nt.reset(); value = workRegion.get(key, this); long duration = nt.reset(); Log.getLogWriter().info("Done getting " + aStr + "; get took " + TestHelper.nanosToString(duration)); } catch (TimeoutException e) { String aStr = key + " with value " + TestHelper.toString(value) + " in " + TestHelper.regionToString(workRegion, false); Log.getLogWriter().info("Putting " + aStr); nt.reset(); workRegion.put(key, value); long duration = nt.reset(); Log.getLogWriter().info("Done putting " + aStr + "; put took " + TestHelper.nanosToString(duration)); } catch (Exception e) {
public void testReset() { final long slop = calculateSlop(); NanoTimer nt = new NanoTimer(); long createTime = NanoTimer.getTime(); assertApproximate("create time", slop, 0, nt.getTimeSinceConstruction()); assertApproximate("construction vs. reset", slop, nt.getTimeSinceConstruction(), nt.getTimeSinceReset()); assertApproximate("time since reset time same as construct", slop, NanoTimer.getTime() - createTime, nt.getTimeSinceReset()); assertApproximate("reset time same as construct", slop, NanoTimer.getTime() - createTime, nt.reset()); long resetTime = NanoTimer.getTime(); assertApproximate("reset time updated", slop, NanoTimer.getTime() - resetTime, nt.getTimeSinceReset()); }