Skip to content

Commit

Permalink
benchmark: Add CSV header (#277)
Browse files Browse the repository at this point in the history
* benchmark: Add CSV header
  • Loading branch information
klauspost authored Mar 27, 2024
1 parent 85a5e93 commit 465e91a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions benchmark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func main() {
if sz > math.MaxInt || sz < 0 {
exitErr(errors.New("block size invalid"))
}
if *csv {
fmt.Printf("op\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "k", "m", "bsize", "blocks", "concurrency", "codec", "processed bytes", "duration (μs)", "speed ("+sizeUint+"/s)")
}
dataSz := int(sz)
each := (dataSz + *kShards - 1) / *kShards

Expand Down Expand Up @@ -157,7 +160,7 @@ func benchmarkEncoding(enc reedsolomon.Encoder, data [][][]byte) {
encGB := float64(finished) * (1 / speedDivisor)
speed := encGB / (float64(time.Since(start)) / float64(time.Second))
if *csv {
fmt.Printf("encode\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", *kShards, *mShards, *blockSize, *blocks, *cpu, *codec, finished, time.Since(start).Microseconds(), speed)
fmt.Printf("encode\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", *kShards, *mShards, *blockSize, *blocks, *cpu, *codec, finished, time.Since(start).Microseconds(), speed*speedBitMul)
} else {
fmt.Printf("\r * Encoded %.00f %s in %v. Speed: %.02f %s (%d+%d:%d)\n", encGB, sizeUint, time.Since(start).Round(time.Millisecond), speedBitMul*speed, speedUnit, dataShards, parityShards, len(data[0][0]))
}
Expand Down Expand Up @@ -210,7 +213,7 @@ func benchmarkEncodingConcurrent(enc reedsolomon.Encoder, data [][][]byte) {
encGB := float64(finished) * (1 / speedDivisor)
speed := encGB / (float64(time.Since(start)) / float64(time.Second))
if *csv {
fmt.Printf("encode conc\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", *kShards, *mShards, *blockSize, *blocks, *cpu, *codec, finished, time.Since(start).Microseconds(), speed)
fmt.Printf("encode conc\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", *kShards, *mShards, *blockSize, *blocks, *cpu, *codec, finished, time.Since(start).Microseconds(), speed*speedBitMul)
} else {
fmt.Printf("\r * Encoded concurrent %.00f %s in %v. Speed: %.02f %s (%d+%d:%d/%d)\n", encGB, sizeUint, time.Since(start).Round(time.Millisecond), speedBitMul*speed, speedUnit, dataShards, parityShards, len(data[0][0]), len(data))
}
Expand Down

0 comments on commit 465e91a

Please sign in to comment.