scylladb / scylla-bench

42 stars 34 forks source link

Excessive precision in output #44

Closed nyh closed 3 years ago

nyh commented 3 years ago

When I run

./scylla-bench -workload uniform -mode read -partition-count 5 -duration 10s

I get output lines like

time                operations/s   rows/s   errors  max              99.9th           99th             95th             90th             median           mean             
9.006293118s               26534    26534        0  3.047423ms       1.966079ms       1.179647ms       917.503µs        819.199µs        589.823µs        602.173µs        

There is no need for this amount of precision (apparently nanoseconds) in the time measurements. It's not helpful, and makes the output line very long and inconvenient to view without deliberately starting an extremely wide terminal window.

nyh commented 3 years ago

Unfortunately, our code just prints these time.Duration objects using the default formatting (%v) and this has some fixed logic on how to print things - see https://github.com/golang/go/blob/2bbb57c9d4/src/time/time.go#L700-L703. In particular, durations smaller than one milliseconds are shows as microseconds with 3 digits after the decimal points, and durations between 1ms and 1s are shown as ms with 6 digits after the decimal point, and durations more than 1s are shown with 9 digits after the decimal point! This is exactly what we see in the output above, and is extremely ugly. See also https://stackoverflow.com/questions/58414820/limiting-significant-digits-in-formatted-durations

I think we have no choice but to write our own Duration-to-String function and use that, instead of the standard one.