Improve pretty printing

This commit is contained in:
Bodigrim 2021-02-07 17:26:23 +00:00
parent ede45c1e30
commit 51a5288b45

View File

@ -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