1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
3 Date: Sat, 4 Nov 2017 21:33:28 +0100
4 Subject: [PATCH] Rewrite fHits() in arc_summary.py with SI units
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Complete rewrite of fHits(). Move units from non-standard English
10 abbreviations to SI units, thereby avoiding confusion because of
11 "long scale" and "short scale" numbers. Remove unused parameter
12 "Decimal". Add function string. Aim to confirm to PEP8.
14 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
15 Reviewed-by: George Melikov <mail@gmelikov.ru>
16 Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
17 Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
19 (cherry picked from commit 88e4e0d5dd1800add5191633d65797ce1c2eb4cf)
20 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
22 cmd/arc_summary/arc_summary.py | 62 ++++++++++++++++++++++--------------------
23 1 file changed, 33 insertions(+), 29 deletions(-)
25 diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
26 index 6b818edc7..cbb7d20bc 100755
27 --- a/cmd/arc_summary/arc_summary.py
28 +++ b/cmd/arc_summary/arc_summary.py
29 @@ -111,36 +111,40 @@ def fBytes(b=0):
33 -def fHits(Hits=0, Decimal=2):
44 - return str("%0." + str(Decimal) + "f") % (Hits / Shits) + "S"
46 - return str("%0." + str(Decimal) + "f") % (Hits / shits) + "s"
48 - return str("%0." + str(Decimal) + "f") % (Hits / Qhits) + "Q"
50 - return str("%0." + str(Decimal) + "f") % (Hits / qhits) + "q"
52 - return str("%0." + str(Decimal) + "f") % (Hits / thits) + "t"
54 - return str("%0." + str(Decimal) + "f") % (Hits / bhits) + "b"
56 - return str("%0." + str(Decimal) + "f") % (Hits / mhits) + "m"
58 - return str("%0." + str(Decimal) + "f") % (Hits / khits) + "k"
60 - return str("%d" % 0)
62 + """Create a human-readable representation of the number of hits.
63 + The single-letter symbols used are SI to avoid the confusion caused
64 + by the different "short scale" and "long scale" representations in
65 + English, which use the same words for different values. See
66 + https://en.wikipedia.org/wiki/Names_of_large_numbers and
67 + https://physics.nist.gov/cuu/Units/prefixes.html
71 + [10**24, 'Y'], # yotta (septillion)
72 + [10**21, 'Z'], # zetta (sextillion)
73 + [10**18, 'E'], # exa (quintrillion)
74 + [10**15, 'P'], # peta (quadrillion)
75 + [10**12, 'T'], # tera (trillion)
76 + [10**9, 'G'], # giga (billion)
77 + [10**6, 'M'], # mega (million)
78 + [10**3, 'k']] # kilo (thousand)
82 + for limit, symbol in numbers:
88 + result = "%0.2f%s" % (value, symbol)
91 - return str("%d" % Hits)
93 + result = "%d" % hits
98 def fPerc(lVal=0, rVal=0, Decimal=2):