Skip to content

Commit 3db84f1

Browse files
authored
Fix unit typo in benchmark (#252)
1 parent 5231646 commit 3db84f1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

benchmark/main.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ var spin = [...]byte{'|', '/', '-', '\\'}
120120
/*
121121
const speedDivisor = float64(1 << 30)
122122
const speedUnit = "Gbps"
123+
const sizeUint = "GiB"
123124
const speedBitMul = 8
124125
*/
125126

126127
const speedDivisor = float64(1 << 20)
127128
const speedUnit = "MiB/s"
129+
const sizeUint = "MiB"
128130
const speedBitMul = 1
129131

130132
func benchmarkEncoding(enc reedsolomon.Encoder, data [][][]byte) {
@@ -145,7 +147,7 @@ func benchmarkEncoding(enc reedsolomon.Encoder, data [][][]byte) {
145147
if *progress && time.Since(lastUpdate) > updateFreq {
146148
encGB := float64(finished) * (1 / speedDivisor)
147149
speed := encGB / (float64(time.Since(start)) / float64(time.Second))
148-
fmt.Printf("\r %s Encoded: %.02f GiB @%.02f %s.", string(spin[spinIdx]), encGB, speed*speedBitMul, speedUnit)
150+
fmt.Printf("\r %s Encoded: %.02f %s @%.02f %s.", string(spin[spinIdx]), encGB, sizeUint, speed*speedBitMul, speedUnit)
149151
spinIdx = (spinIdx + 1) % len(spin)
150152
lastUpdate = time.Now()
151153
}
@@ -156,7 +158,7 @@ func benchmarkEncoding(enc reedsolomon.Encoder, data [][][]byte) {
156158
if *csv {
157159
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)
158160
} else {
159-
fmt.Printf("\r * Encoded %.00f GiB in %v. Speed: %.02f %s (%d+%d:%d)\n", encGB, time.Since(start).Round(time.Millisecond), speedBitMul*speed, speedUnit, dataShards, parityShards, len(data[0][0]))
161+
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]))
160162
}
161163
}
162164

@@ -198,7 +200,7 @@ func benchmarkEncodingConcurrent(enc reedsolomon.Encoder, data [][][]byte) {
198200
if *progress {
199201
encGB := float64(atomic.LoadInt64(&finished)) * (1 / speedDivisor)
200202
speed := encGB / (float64(time.Since(start)) / float64(time.Second))
201-
fmt.Printf("\r %s Encoded: %.02f GiB @%.02f %s.", string(spin[spinIdx]), encGB, speed*speedBitMul, speedUnit)
203+
fmt.Printf("\r %s Encoded: %.02f %s @%.02f %s.", string(spin[spinIdx]), encGB, sizeUint, speed*speedBitMul, speedUnit)
202204
spinIdx = (spinIdx + 1) % len(spin)
203205
}
204206
}
@@ -209,7 +211,7 @@ func benchmarkEncodingConcurrent(enc reedsolomon.Encoder, data [][][]byte) {
209211
if *csv {
210212
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)
211213
} else {
212-
fmt.Printf("\r * Encoded concurrent %.00f GiB in %v. Speed: %.02f %s (%d+%d:%d/%d)\n", encGB, time.Since(start).Round(time.Millisecond), speedBitMul*speed, speedUnit, dataShards, parityShards, len(data[0][0]), len(data))
214+
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))
213215
}
214216
}
215217

@@ -249,7 +251,7 @@ func benchmarkDecoding(enc reedsolomon.Encoder, data [][][]byte) {
249251
if *progress && time.Since(lastUpdate) > updateFreq {
250252
encGB := float64(finished) * (1 / speedDivisor)
251253
speed := encGB / (float64(time.Since(start)) / float64(time.Second))
252-
fmt.Printf("\r %s Repaired: %.02f GiB @%.02f %s.", string(spin[spinIdx]), encGB, speed*speedBitMul, speedUnit)
254+
fmt.Printf("\r %s Repaired: %.02f %s @%.02f %s.", string(spin[spinIdx]), encGB, sizeUint, speed*speedBitMul, speedUnit)
253255
spinIdx = (spinIdx + 1) % len(spin)
254256
lastUpdate = time.Now()
255257
}
@@ -260,7 +262,7 @@ func benchmarkDecoding(enc reedsolomon.Encoder, data [][][]byte) {
260262
if *csv {
261263
fmt.Printf("decode\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)
262264
} else {
263-
fmt.Printf("\r * Repaired %.00f GiB in %v. Speed: %.02f %s (%d+%d:%d)\n", encGB, time.Since(start).Round(time.Millisecond), speedBitMul*speed, speedUnit, dataShards, parityShards, len(data[0][0]))
265+
fmt.Printf("\r * Repaired %.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]))
264266
}
265267
}
266268

@@ -318,7 +320,7 @@ func benchmarkDecodingConcurrent(enc reedsolomon.Encoder, data [][][]byte) {
318320
if *progress {
319321
encGB := float64(finished) * (1 / speedDivisor)
320322
speed := encGB / (float64(time.Since(start)) / float64(time.Second))
321-
fmt.Printf("\r %s Repaired: %.02f GiB @%.02f %s.", string(spin[spinIdx]), encGB, speed*speedBitMul, speedUnit)
323+
fmt.Printf("\r %s Repaired: %.02f %s @%.02f %s.", string(spin[spinIdx]), encGB, sizeUint, speed*speedBitMul, speedUnit)
322324
spinIdx = (spinIdx + 1) % len(spin)
323325
}
324326
}
@@ -327,7 +329,7 @@ func benchmarkDecodingConcurrent(enc reedsolomon.Encoder, data [][][]byte) {
327329
if *csv {
328330
fmt.Printf("decode 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)
329331
} else {
330-
fmt.Printf("\r * Repaired concurrent %.00f GiB in %v. Speed: %.02f %s (%d+%d:%d/%d)\n", encGB, time.Since(start).Round(time.Millisecond), speedBitMul*speed, speedUnit, dataShards, parityShards, len(data[0][0]), len(data))
332+
fmt.Printf("\r * Repaired 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))
331333
}
332334
}
333335

0 commit comments

Comments
 (0)