• Kirill Smelkov's avatar
    benchstat: skip empty rows when just dumping data · 2e294072
    Kirill Smelkov authored
    When comparing 2 files, benchstat skips rows that are not present in
    both benchmarks. However currently when benchstat'ing just 1 file or 3
    or more, benchstat dumps every row for every unit, even if row results
    for the unit are completely empty.
    
    When several units are in use, this creates a lot of noise of empty
    benchmark lines output. For example for the following benchmark
    
    ```
    BenchmarkTwoHourMarathon 1 7200000000000 ns/op 14400000000000 user-ns/op 5 ns/GC 12 quick-bytes
    BenchmarkTwoHourMarathon 1 7200000000000 ns/op 14500000000000 user-ns/op 5 ns/GC 16 quick-bytes
    BenchmarkTwoHourMarathon 1 7200000000000 ns/op 14600000000000 user-ns/op 5 ns/GC 12 quick-bytes
    BenchmarkTwoHourMarathon 1 7200000000000 ns/op 14200000000000 user-ns/op 5 ns/GC 16 quick-bytes
    BenchmarkTwoHourMarathon 1 7200000000000 ns/op 14300000000000 user-ns/op 5 ns/GC 12 quick-bytes
    
    BenchmarkTimens 1 31 ns/op 21 user-ns/op
    BenchmarkTimeμs 1 32 μs/op 22 user-μs/op	# mu = U+03bc
    BenchmarkTimeµs 1 33 µs/op 23 user-µs/op	# mu = U+b5
    BenchmarkTimeus 1 34 us/op 24 user-us/op
    BenchmarkTimems 1 35 ms/op 25 user-ms/op
    BenchmarkTimes  1 36  s/op 26 user-s/op
    
    BenchmarkTimeObjectns 1 41 ns/object
    BenchmarkTimeObjectµs 1 42 µs/object
    BenchmarkTimeObjectus 1 43 us/object
    BenchmarkTimeObjectms 1 44 ms/object
    BenchmarkTimeObjects  1 45 s/object
    ```
    
    current output is
    
    ```
    name             time/op
    TwoHourMarathon    7200s ± 0%
    Timens            31.0ns ± 0%
    Timeμs            32.0µs ± 0%
    Timeµs            33.0µs ± 0%
    Timeus            34.0µs ± 0%
    Timems            35.0ms ± 0%
    Times              36.0s ± 0%
    TimeObjectns
    TimeObjectµs
    TimeObjectus
    TimeObjectms
    TimeObjects
    
    name             user-time/op
    TwoHourMarathon   14400s ± 1%
    Timens            21.0ns ± 0%
    Timeμs            22.0µs ± 0%
    Timeµs            23.0µs ± 0%
    Timeus            24.0µs ± 0%
    Timems            25.0ms ± 0%
    Times              26.0s ± 0%
    TimeObjectns
    TimeObjectµs
    TimeObjectus
    TimeObjectms
    TimeObjects
    
    name             time/GC
    TwoHourMarathon   5.00ns ± 0%
    Timens
    Timeμs
    Timeµs
    Timeus
    Timems
    Times
    TimeObjectns
    TimeObjectµs
    TimeObjectus
    TimeObjectms
    TimeObjects
    
    name             quick-bytes
    TwoHourMarathon    13.6B ±18%
    Timens
    Timeμs
    Timeµs
    Timeus
    Timems
    Times
    TimeObjectns
    TimeObjectµs
    TimeObjectus
    TimeObjectms
    TimeObjects
    
    name             time/object
    TwoHourMarathon
    Timens
    Timeμs
    Timeµs
    Timeus
    Timems
    Times
    TimeObjectns      41.0ns ± 0%
    TimeObjectµs      42.0µs ± 0%
    TimeObjectus      43.0µs ± 0%
    TimeObjectms      44.0ms ± 0%
    TimeObjects        45.0s ± 0%
    ```
    
    and it becomes
    
    ```
    name             time/op
    TwoHourMarathon    7200s ± 0%
    Timens            31.0ns ± 0%
    Timeμs            32.0µs ± 0%
    Timeµs            33.0µs ± 0%
    Timeus            34.0µs ± 0%
    Timems            35.0ms ± 0%
    Times              36.0s ± 0%
    
    name             user-time/op
    TwoHourMarathon   14400s ± 1%
    Timens            21.0ns ± 0%
    Timeμs            22.0µs ± 0%
    Timeµs            23.0µs ± 0%
    Timeus            24.0µs ± 0%
    Timems            25.0ms ± 0%
    Times              26.0s ± 0%
    
    name             time/GC
    TwoHourMarathon   5.00ns ± 0%
    
    name             quick-bytes
    TwoHourMarathon    13.6B ±18%
    
    name             time/object
    TimeObjectns      41.0ns ± 0%
    TimeObjectµs      42.0µs ± 0%
    TimeObjectus      43.0µs ± 0%
    TimeObjectms      44.0ms ± 0%
    TimeObjects        45.0s ± 0%
    ```
    
    after this patch.
    
    Change-Id: Ic260e39913af7b2c3aa1ff850aed65002d553d6c
    2e294072
main_test.go 2.79 KB