@Test public void testStatisticLongAdder() throws InterruptedException { AtomicInteger atomicInteger = new AtomicInteger(0); StatisticNode statisticNode = new StatisticNode(); ExecutorService bizEs1 = new ThreadPoolExecutor(THREAD_COUNT, THREAD_COUNT, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); ExecutorService bizEs2 = new ThreadPoolExecutor(THREAD_COUNT, THREAD_COUNT, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); int taskCount = 100; for (int i = 0; i < taskCount; i++) { int op = i % 2; bizEs2.submit(new StatisticAtomicIntegerTask(atomicInteger, op, i)); bizEs1.submit(new StatisticLongAdderTask(statisticNode, op, i)); } Thread.sleep(5000); log("LongAdder totalCost : " + StatisticLongAdderTask.totalCost() + "ms"); log("AtomicInteger totalCost : " + StatisticAtomicIntegerTask.totalCost() + "ms"); Assert.assertEquals(statisticNode.curThreadNum(), atomicInteger.get()); }
@Override public int curThreadNum() { return (int)curThreadNum.sum(); }
StatisticNode implements Node { @Override public int curThreadNum() { return (int)curThreadNum.sum(); } }
StatisticNode implements Node { @Override public int curThreadNum() { return (int)curThreadNum.sum(); }  }
StatisticNode implements Node { @Override public int curThreadNum() { return (int)curThreadNum.sum(); }  @Override Map<Long, MetricNode> metrics(); @Override void reset(); @Override long totalRequest(); @Override long blockRequest(); @Override double blockQps(); @Override double previousBlockQps(); @Override double previousPassQps(); @Override double totalQps(); @Override long totalSuccess(); @Override double exceptionQps(); @Override long totalException(); @Override double passQps(); @Override long totalPass(); @Override double successQps(); @Override double maxSuccessQps(); @Override double occupiedPassQps(); @Override double avgRt(); @Override double minRt(); @Override int curThreadNum(); @Override void addPassRequest(int count); @Override void addRtAndSuccess(long rt, int successCount); @Override void increaseBlockQps(int count); @Override void increaseExceptionQps(int count); @Override void increaseThreadNum(); @Override void decreaseThreadNum(); @Override void debug(); @Override long tryOccupyNext(long currentTime, int acquireCount, double threshold); @Override long waiting(); @Override void addWaitingRequest(long futureTime, int acquireCount); @Override void addOccupiedPass(int acquireCount); }
StatisticNode implements Node { @Override public int curThreadNum() { return (int)curThreadNum.sum(); }  @Override Map<Long, MetricNode> metrics(); @Override void reset(); @Override long totalRequest(); @Override long blockRequest(); @Override double blockQps(); @Override double previousBlockQps(); @Override double previousPassQps(); @Override double totalQps(); @Override long totalSuccess(); @Override double exceptionQps(); @Override long totalException(); @Override double passQps(); @Override long totalPass(); @Override double successQps(); @Override double maxSuccessQps(); @Override double occupiedPassQps(); @Override double avgRt(); @Override double minRt(); @Override int curThreadNum(); @Override void addPassRequest(int count); @Override void addRtAndSuccess(long rt, int successCount); @Override void increaseBlockQps(int count); @Override void increaseExceptionQps(int count); @Override void increaseThreadNum(); @Override void decreaseThreadNum(); @Override void debug(); @Override long tryOccupyNext(long currentTime, int acquireCount, double threshold); @Override long waiting(); @Override void addWaitingRequest(long futureTime, int acquireCount); @Override void addOccupiedPass(int acquireCount);  }