CallStackElement { static String printPercentAsBar(double percent, int totalBars, boolean asciiArt) { int actualBars = (int) (percent * totalBars); boolean includeHalfBarAtEnd = actualBars * 2 != (int) (percent * totalBars * 2); StringBuilder sb = new StringBuilder(totalBars); for (int i = 0; i < totalBars; i++) { if (i < actualBars) { sb.append(asciiArt ? (char) 9608 : '|'); } else if (i == actualBars && includeHalfBarAtEnd) { sb.append(asciiArt ? (char) 9619 : ':'); } else { sb.append(asciiArt ? (char) 9617 : '-'); } } return sb.toString(); }  static CallStackElement createRoot(String signature); static CallStackElement create(CallStackElement parent, String signature); static CallStackElement create(CallStackElement parent, String signature, long startTimestamp); void recycle(); void removeCallsFasterThan(long thresholdNs); boolean isIOQuery(); long getExecutionTime(); void setExecutionTime(long executionTime); long getNetExecutionTime(); void incrementExecutionTime(long additionalExecutionTime); List<CallStackElement> getChildren(); void setChildren(List<CallStackElement> children); String getSignature(); void setSignature(String signature); String getShortSignature(); CallStackElement getParent(); void setParent(CallStackElement parent); void remove(); void executionStopped(long executionTime); CallStackElement executionStopped(long timestamp, long minExecutionTime); @Override String toString(); String toString(boolean asciiArt, AsciiCallTreeSignatureFormatter callTreeAsciiFormatter);  }
@Test public void printPercentAsBar() throws Exception { Assert.assertEquals("|||||-----", CallStackElement.printPercentAsBar(0.54d, 10, false)); char[] chars = {9608, 9608, 9608, 9608, 9608, 9619, 9617, 9617, 9617, 9617}; Assert.assertEquals(new String(chars), CallStackElement.printPercentAsBar(0.56d, 10, true)); }