diff options
author | Nick White <git@njw.name> | 2019-05-14 15:40:12 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2019-05-14 15:40:12 +0100 |
commit | 544c42ebae13c4f215a0722b4067d4adb715be65 (patch) | |
tree | 6a1bfa7b4441f7828e08ad44cbe95faf625a2cb0 | |
parent | 6b4e704befb7f82627d2c9a4e3f4e2971fdaf883 (diff) |
pgconf: Don't print NaN if a page has no lines, and show the percentage, rather than float, for easier comparison
-rw-r--r-- | pgconf/main.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pgconf/main.go b/pgconf/main.go index 1b70ecc..d254f42 100644 --- a/pgconf/main.go +++ b/pgconf/main.go @@ -37,11 +37,16 @@ func main() { } } + if len(lines) == 0 { + fmt.Printf("No lines found\n") + os.Exit(0) + } + var total float64 for _, l := range lines { total += l.Avgconf } avg := total / float64(len(lines)) - fmt.Printf("%0.2f\n", avg) + fmt.Printf("%0.0f\n", avg * 100) } |