From 51a5288b45d8118807cace1b321d57fe19d40fae Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Sun, 7 Feb 2021 17:26:23 +0000 Subject: [PATCH] Improve pretty printing --- Test/Tasty/Bench.hs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Test/Tasty/Bench.hs b/Test/Tasty/Bench.hs index c3045a8..bf98127 100644 --- a/Test/Tasty/Bench.hs +++ b/Test/Tasty/Bench.hs @@ -484,21 +484,26 @@ showPicos i | t < 995e6 = printf "%3.0f μs" (t / 1e6) | t < 995e7 = printf "%3.1f ms" (t / 1e9) | t < 995e9 = printf "%3.0f ms" (t / 1e9) - | otherwise = printf "%.1f s" (t / 1e12) + | otherwise = printf "%4.2f s" (t / 1e12) where t :: Double t = fromIntegral i showBytes :: Word64 -> String showBytes i - | t < 1000 = printf "%3.0f B " t - | t < 10189 = printf "%3.1f KB" (t / 1024) - | t < 1023488 = printf "%3.0f KB" (t / 1024) - | t < 10433332 = printf "%3.1f MB" (t / 1048576) - | t < 1048051712 = printf "%3.0f MB" (t / 1048576) - | t < 10683731149 = printf "%3.1f GB" (t / 1073741824) - | t < 1073204953088 = printf "%3.0f GB" (t / 1073741824) - | otherwise = printf "%.1f TB" (t / 1099511627776) + | t < 1000 = printf "%3.0f B " t + | t < 10189 = printf "%3.1f KB" (t / 1024) + | t < 1023488 = printf "%3.0f KB" (t / 1024) + | t < 10433332 = printf "%3.1f MB" (t / 1048576) + | t < 1048051712 = printf "%3.0f MB" (t / 1048576) + | t < 10683731149 = printf "%3.1f GB" (t / 1073741824) + | t < 1073204953088 = printf "%3.0f GB" (t / 1073741824) + | t < 10940140696372 = printf "%3.1f TB" (t / 1099511627776) + | t < 1098961871962112 = printf "%3.0f TB" (t / 1099511627776) + | t < 11202704073084108 = printf "%3.1f PB" (t / 1125899906842624) + | t < 1125336956889202624 = printf "%3.0f PB" (t / 1125899906842624) + | t < 11471568970838126592 = printf "%3.1f EB" (t / 1152921504606846976) + | otherwise = printf "%3.0f EB" (t / 1152921504606846976) where t :: Double t = fromIntegral i