public static void main(String[] args) { testMaxThroughput(); }
println(THREADS_NUM + " tasks, " + THREAD_SUBMIT_NUM * THREADS_NUM + " submit cost " + (submitEnd - submitStart) / 1000D + "seconds"); long totalStart = System.currentTimeMillis(); while (!allTasksReady()) { try { println(THREADS_NUM + " tasks, " + THREAD_SUBMIT_NUM * THREADS_NUM + " requests cost " + (totalEnd - totalStart) / 1000D + "seconds"); printStatistics(totalCostTimesBook); try { service.shutdownNow();
private static void printStatistics(List<double[]> data) { List<Double> totalPoints = new ArrayList<>(); double total = 0D; for (double[] item : data) { for (Double point : item) { if (point != null) { totalPoints.add(point); total += point; } } } Double[] totalPointsArray = new Double[totalPoints.size()]; totalPoints.toArray(totalPointsArray); Arrays.sort(totalPointsArray); // printTimeCostArray(totalPointsArray); println("===== statistics ================"); println("===== min time cost: " + totalPointsArray[0] + " ====="); println("===== max time cost: " + totalPointsArray[totalPointsArray.length - 2] + " ====="); double meanVal = total / totalPointsArray.length; println("===== mean time cost: " + meanVal + " ====="); int middleIndex = (int) (totalPointsArray.length * 0.5); println("===== median time cost: " + totalPointsArray[middleIndex] + " ====="); int top90Index = (int) (totalPointsArray.length * 0.9); println("===== top90 time cost: " + totalPointsArray[top90Index] + " ====="); }