RFR: 5721: Reintroduce the Percentage column

Henrik Dafgård hdafgard at openjdk.java.net
Mon Dec 16 16:48:15 UTC 2019


On Sat, 7 Dec 2019 14:43:49 GMT, Dmitry Popov <github.com+7112604+dmnm at openjdk.org> wrote:

> This patch addresses [JMC-5721](https://bugs.openjdk.java.net/browse/JMC-5721): Reintroduce the Percentage column.
> 
> 1. StacktraceView has been amended to display Percentage column as well it displays stack trace and count ones. Percentage format is #.## (up-to 2 decimal points), it will also arbitrarily round the number.
> 2. Tool tip with frame fraction and sibling groups info has been moved from Count column to Percentage.
> 3. Currently Background drawer decorates Percentage column instead of Count.

application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/views/stacktrace/StacktraceView.java line 738:

> 737: 			int totalCount = getRootFork(frame.getBranch().getParentFork()).getItemsInFork();
> 738: 			return String.format("%.2f%%", (itemCount / (float) totalCount) * 100F);
> 739: 		}

You should use the unit toolkit we have for displaying the percentage, i.e. use UnitLookup.PERCENT_UNITY.quantity to get a value, and then format it as a string using .displayUsing and pass in an appropriate formatting hint. For this I'd say that running 

> UnitLookup.PERCENT_UNITY.quantity(itemCount / (float) totalCount).displayUsing(IDisplayable.AUTO)

 will work fine, but feel free to try some alternatives.

-------------

Changes requested by hdafgard (Reviewer).

PR: https://git.openjdk.java.net/jmc/pull/12


More information about the jmc-dev mailing list