From 3f8494c8a4aaeb0176c38d22bb52ba221930454d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 21 Mar 2023 11:04:25 +1100 Subject: [PATCH] Just use one decimal place for all percentages. Simpler, shorter, and good enough in practice. --- cachegrind/cg_annotate.in | 7 +- cachegrind/tests/ann2.post.exp | 36 ++++----- cachegrind/tests/ann3.post.exp | 136 ++++++++++++++++----------------- 3 files changed, 87 insertions(+), 92 deletions(-) diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index e7d094b50d..ac2f2b792a 100755 --- a/cachegrind/cg_annotate.in +++ b/cachegrind/cg_annotate.in @@ -528,12 +528,7 @@ class CcPrinter: perc = " (n/a)" else: p = cc.counts[i] * 100 / summary_count - # Use just one decimal place for large percentages. - if abs(p) < 100: - w = 2 - else: - w = 1 - perc = f" ({p:.{w}f}%)" + perc = f" ({p:.1f}%)" else: perc = "" diff --git a/cachegrind/tests/ann2.post.exp b/cachegrind/tests/ann2.post.exp index 8d33c9e79a..4428346813 100644 --- a/cachegrind/tests/ann2.post.exp +++ b/cachegrind/tests/ann2.post.exp @@ -18,30 +18,30 @@ Dw Dr Ir 18,005 (100.0%) 4,057,955 (100.0%) 5,229,753 (100.0%) PROGRAM TOTALS -------------------------------------------------------------------------------- -Dw Dr Ir file:function --------------------------------------------------------------------------------- - 3 (0.02%) 4,000,004 (98.57%) 5,000,015 (95.61%) a.c:main -4,543 (25.23%) 17,566 (0.43%) 47,993 (0.92%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:do_lookup_x -3,083 (17.12%) 5,750 (0.14%) 28,534 (0.55%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:_dl_lookup_symbol_x - 8 (0.04%) 5,521 (0.14%) 28,136 (0.54%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-tunables.c:__GI___tunables_init -2,490 (13.83%) 5,219 (0.13%) 21,821 (0.42%) /build/glibc-OTsEL5/glibc-2.27/elf/../sysdeps/x86_64/dl-machine.h:_dl_relocate_object - 0 5,158 (0.13%) 25,408 (0.49%) /build/glibc-OTsEL5/glibc-2.27/string/../sysdeps/x86_64/strcmp.S:strcmp +Dw Dr Ir file:function +-------------------------------------------------------------------------------- + 3 (0.0%) 4,000,004 (98.6%) 5,000,015 (95.6%) a.c:main +4,543 (25.2%) 17,566 (0.4%) 47,993 (0.9%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:do_lookup_x +3,083 (17.1%) 5,750 (0.1%) 28,534 (0.5%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c:_dl_lookup_symbol_x + 8 (0.0%) 5,521 (0.1%) 28,136 (0.5%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-tunables.c:__GI___tunables_init +2,490 (13.8%) 5,219 (0.1%) 21,821 (0.4%) /build/glibc-OTsEL5/glibc-2.27/elf/../sysdeps/x86_64/dl-machine.h:_dl_relocate_object + 0 5,158 (0.1%) 25,408 (0.5%) /build/glibc-OTsEL5/glibc-2.27/string/../sysdeps/x86_64/strcmp.S:strcmp -------------------------------------------------------------------------------- -- User-annotated source: a.c -------------------------------------------------------------------------------- -Dw Dr Ir +Dw Dr Ir - 1 (0.01%) 0 2 (0.00%) int main(void) { - 1 (0.01%) 0 1 (0.00%) int z = 0; - 1 (0.01%) 2,000,001 (49.29%) 3,000,004 (57.36%) for (int i = 0; i < 1000000; i++) { - 0 2,000,000 (49.29%) 2,000,000 (38.24%) z += i; - . . . } - 0 1 (0.00%) 6 (0.00%) return z % 256; - 0 2 (0.00%) 2 (0.00%) } + 1 (0.0%) 0 2 (0.0%) int main(void) { + 1 (0.0%) 0 1 (0.0%) int z = 0; + 1 (0.0%) 2,000,001 (49.3%) 3,000,004 (57.4%) for (int i = 0; i < 1000000; i++) { + 0 2,000,000 (49.3%) 2,000,000 (38.2%) z += i; + . . . } + 0 1 (0.0%) 6 (0.0%) return z % 256; + 0 2 (0.0%) 2 (0.0%) } -------------------------------------------------------------------------------- -Dw Dr Ir +Dw Dr Ir -------------------------------------------------------------------------------- - 3 (0.02%) 4,000,004 (98.57%) 5,000,015 (95.61%) events annotated + 3 (0.0%) 4,000,004 (98.6%) 5,000,015 (95.6%) events annotated diff --git a/cachegrind/tests/ann3.post.exp b/cachegrind/tests/ann3.post.exp index 52c5b87503..063715aa6f 100644 --- a/cachegrind/tests/ann3.post.exp +++ b/cachegrind/tests/ann3.post.exp @@ -18,48 +18,48 @@ A SomeCount VeryLongEventName 100,000 (100.0%) 100,000 (100.0%) 0 PROGRAM TOTALS -------------------------------------------------------------------------------- -A SomeCount VeryLongEventName file:function --------------------------------------------------------------------------------- -70,491 (70.49%) 90,491 (90.49%) 0 ann3-basic.rs:f0 -15,000 (15.00%) 600 (0.60%) 0 ann3-basic.rs:f1 - 9,000 (9.00%) 6,000 (6.00%) 0 ann3-could-not-be-found.rs:f1 - 2,000 (2.00%) 100 (0.10%) 0 ann3-basic.rs:f2 - 1,000 (1.00%) 500 (0.50%) 0 ann3-via-I.rs:f1 - 1,000 (1.00%) 300 (0.30%) -1,000 (n/a) ann3-past-the-end.rs:f1 --1,000 (-1.00%) 0 0 ann3-negatives.rs:neg3 --1,000 (-1.00%) 0 0 ann3-negatives.rs:neg2 - 1,000 (1.00%) 0 0 ann3-more-recent-than-cgout.rs:new - 1,000 (1.00%) 0 0 ???:unknown - 500 (0.50%) 0 0 ann3-basic.rs:f6 - 500 (0.50%) 0 0 ann3-basic.rs:f4 +A SomeCount VeryLongEventName file:function +-------------------------------------------------------------------------------- +70,491 (70.5%) 90,491 (90.5%) 0 ann3-basic.rs:f0 +15,000 (15.0%) 600 (0.6%) 0 ann3-basic.rs:f1 + 9,000 (9.0%) 6,000 (6.0%) 0 ann3-could-not-be-found.rs:f1 + 2,000 (2.0%) 100 (0.1%) 0 ann3-basic.rs:f2 + 1,000 (1.0%) 500 (0.5%) 0 ann3-via-I.rs:f1 + 1,000 (1.0%) 300 (0.3%) -1,000 (n/a) ann3-past-the-end.rs:f1 +-1,000 (-1.0%) 0 0 ann3-negatives.rs:neg3 +-1,000 (-1.0%) 0 0 ann3-negatives.rs:neg2 + 1,000 (1.0%) 0 0 ann3-more-recent-than-cgout.rs:new + 1,000 (1.0%) 0 0 ???:unknown + 500 (0.5%) 0 0 ann3-basic.rs:f6 + 500 (0.5%) 0 0 ann3-basic.rs:f4 -------------------------------------------------------------------------------- -- Auto-annotated source: ann3-basic.rs -------------------------------------------------------------------------------- -A SomeCount VeryLongEventName +A SomeCount VeryLongEventName -- line 2 ---------------------------------------- - . . . two - . . . three - 5,000 (5.00%) 500 (0.50%) 0 four - 5,000 (5.00%) 100 (0.10%) 0 five - . . . six -70,491 (70.49%) 90,491 (90.49%) 0 seven - . . . eight - 110 (0.11%) 9 (0.01%) 0 nine - . . . ten - . . . eleven - 200 (0.20%) 0 0 twelve - 200 (0.20%) 0 0 thirteen - 100 (0.10%) 0 0 fourteen - 0 0 0 fifteen - 0 0 0 sixteen - 0 0 0 seventeen - 0 0 0 eighteen - 499 (0.50%) 2,000 (2.00%) 0 nineteen - 300 (0.30%) 0 0 twenty - - 7,100 (7.10%) 100 (0.10%) 0 + . . . two + . . . three + 5,000 (5.0%) 500 (0.5%) 0 four + 5,000 (5.0%) 100 (0.1%) 0 five + . . . six +70,491 (70.5%) 90,491 (90.5%) 0 seven + . . . eight + 110 (0.1%) 9 (0.0%) 0 nine + . . . ten + . . . eleven + 200 (0.2%) 0 0 twelve + 200 (0.2%) 0 0 thirteen + 100 (0.1%) 0 0 fourteen + 0 0 0 fifteen + 0 0 0 sixteen + 0 0 0 seventeen + 0 0 0 eighteen + 499 (0.5%) 2,000 (2.0%) 0 nineteen + 300 (0.3%) 0 0 twenty + + 7,100 (7.1%) 100 (0.1%) 0 -------------------------------------------------------------------------------- -- Auto-annotated source: ann3-more-recent-than-cgout.rs @@ -71,49 +71,49 @@ A SomeCount VeryLongEventName @ Annotations may not be correct. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -A SomeCount VeryLongEventName +A SomeCount VeryLongEventName - . . . one -1,000 (1.00%) 0 0 two - . . . three - . . . four + . . . one +1,000 (1.0%) 0 0 two + . . . three + . . . four -- line 4 ---------------------------------------- -------------------------------------------------------------------------------- -- Auto-annotated source: ann3-negatives.rs -------------------------------------------------------------------------------- -A SomeCount VeryLongEventName - - 2,000 (2.00%) 2,000 (2.00%) 2,000 (n/a) one - -1,000 (-1.00%) -1,000 (-1.00%) 0 two - . . . three - . . . four - 999,000 (999.0%) 0 -150,000 (n/a) five --1,000,000 (-1000.0%) 0 150,000 (n/a) six - . . . seven - . . . eight - . . . nine - -10,000 (-10.00%) 0 10 (n/a) ten - 10,000 (10.00%) 0 -20 (n/a) eleven - . . . twelve - . . . thirteen +A SomeCount VeryLongEventName + + 2,000 (2.0%) 2,000 (2.0%) 2,000 (n/a) one + -1,000 (-1.0%) -1,000 (-1.0%) 0 two + . . . three + . . . four + 999,000 (999.0%) 0 -150,000 (n/a) five +-1,000,000 (-1000.0%) 0 150,000 (n/a) six + . . . seven + . . . eight + . . . nine + -10,000 (-10.0%) 0 10 (n/a) ten + 10,000 (10.0%) 0 -20 (n/a) eleven + . . . twelve + . . . thirteen -- line 13 ---------------------------------------- - -2,000 (-2.00%) -1,000 (-1.00%) -990 (n/a) + -2,000 (-2.0%) -1,000 (-1.0%) -990 (n/a) -------------------------------------------------------------------------------- -- Auto-annotated source: ann3-past-the-end.rs -------------------------------------------------------------------------------- -A SomeCount VeryLongEventName +A SomeCount VeryLongEventName -200 (0.20%) 100 (0.10%) 0 one - . . . two - . . . three +200 (0.2%) 100 (0.1%) 0 one + . . . two + . . . three -- line 3 ---------------------------------------- -- line 18 ---------------------------------------- -300 (0.30%) 100 (0.10%) 0 -300 (0.30%) 100 (0.10%) 0 -200 (0.20%) 0 -1,000 (n/a) +300 (0.3%) 100 (0.1%) 0 +300 (0.3%) 100 (0.1%) 0 +200 (0.2%) 0 -1,000 (n/a) @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ @@ -129,9 +129,9 @@ A SomeCount VeryLongEventName -------------------------------------------------------------------------------- -- Auto-annotated source: ann3-aux/ann3-via-I.rs -------------------------------------------------------------------------------- -A SomeCount VeryLongEventName +A SomeCount VeryLongEventName -1,000 (1.00%) 500 (0.50%) 0 one +1,000 (1.0%) 500 (0.5%) 0 one -------------------------------------------------------------------------------- The following files chosen for auto-annotation could not be found: @@ -140,7 +140,7 @@ The following files chosen for auto-annotation could not be found: ann3-no-such-file.rs -------------------------------------------------------------------------------- -A SomeCount VeryLongEventName +A SomeCount VeryLongEventName -------------------------------------------------------------------------------- -84,100 (84.10%) 94,700 (94.70%) 1,990 (n/a) events annotated +84,100 (84.1%) 94,700 (94.7%) 1,990 (n/a) events annotated -- 2.47.2