Skip to content

Commit e44f663

Browse files
committed
Fix bench stupidity
1 parent e944674 commit e44f663

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

bench.go

+4-19
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,17 @@ func generationBenchmark(amount int) []string {
3030
kch := make(chan generator.KeyGenerator)
3131
keys := make([]string, 0)
3232
started := time.Now()
33-
count := 0
3433
for i := 0; i < amount; i++ {
35-
count++
3634
go generator.Generate(oem, kch)
3735
k := <-kch
3836
keys = append(keys, k.String())
3937
}
4038
for i := 0; i < amount; i++ {
41-
count++
4239
go generator.Generate(cd, kch)
4340
k := <-kch
4441
keys = append(keys, k.String())
4542
}
4643
for i := 0; i < amount; i++ {
47-
count++
4844
go generator.Generate(ecd, kch)
4945
k := <-kch
5046
keys = append(keys, k.String())
@@ -57,18 +53,13 @@ func generationBenchmark(amount int) []string {
5753
default:
5854
ended = time.Since(started).Round(time.Microsecond)
5955
}
60-
switch {
61-
case count > 1:
62-
fmt.Printf("Took %s to generate %d keys.\n", ended, count)
63-
case count == 1:
64-
fmt.Printf("Took %s to generate %d key.\n", ended, count)
65-
}
56+
fmt.Printf("Took %s to generate %d keys.\n", ended, len(keys))
6657

6758
return keys
6859
}
6960

7061
// generationBenchmark validates N keys and times it.
71-
func validationBenchmark(keys []string, count int) {
62+
func validationBenchmark(keys []string) {
7263
vch := make(chan bool)
7364
var ki validator.KeyValidator
7465
started := time.Now()
@@ -98,12 +89,6 @@ func validationBenchmark(keys []string, count int) {
9889
default:
9990
ended = time.Since(started).Round(time.Microsecond)
10091
}
101-
switch {
102-
case count > 1:
103-
fmt.Printf("Took %s to validate %d keys.\n", ended, count)
104-
return
105-
case count == 1:
106-
fmt.Printf("Took %s to validate %d key.\n", ended, count)
107-
return
108-
}
92+
93+
fmt.Printf("Took %s to validate %d keys.\n", ended, len(keys))
10994
}

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848
if *bench != 0 {
4949
fmt.Printf("Running key generation/validation benchmark with %d keys of each type...\n", *bench)
5050
k := generationBenchmark(*bench)
51-
validationBenchmark(k, *bench*3)
51+
validationBenchmark(k)
5252
return
5353
}
5454

0 commit comments

Comments
 (0)