RFR: 5721: Reintroduce the Percentage column

Dmitry Popov github.com+7112604+dmnm at openjdk.java.net
Sat Dec 21 07:50:46 UTC 2019


On Mon, 16 Dec 2019 16:47:28 GMT, Henrik Dafgård <hdafgard 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.

Hi Henrik,

Thanks for the comment. Let me explain why I've chosen `String.format()` there. I thought about using unit toolkit but I tried to reintroduce Percentage column the same way as it worked before, i.e. with unit up-to 2 decimal point. UnitLookup.PERCENT_UNITY, which is used in tool tip, displays the percentage in up to 5 decimal points format, like 0.00689 %. I think it's not so useful for the column percentage representation, but it's open for discussion.

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

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


More information about the jmc-dev mailing list