Skip to content

Commit cad7c66

Browse files
committed
Remove unnecessary start/stop of benchmark timer
1 parent b3dc20e commit cad7c66

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

sorting/charfreq_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ func TestCountOccurrences(t *testing.T) {
3131
}
3232

3333
func benchCountOccurrences(b *testing.B, size int) {
34-
b.StopTimer()
3534
s := epiutil.RandStr(size, "0123456789abcdefghijklmnopqrstuvwxyz", rand.NewSource(int64(size)))
36-
b.StartTimer()
35+
b.ResetTimer()
3736
for i := 0; i < b.N; i++ {
3837
CountOccurrences(s)
3938
}

sorting/intersection_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ func TestIntersectSorted(t *testing.T) {
3838
}
3939

4040
func benchIntersectSorted(b *testing.B, size int) {
41-
b.StopTimer()
4241
x := rand.New(rand.NewSource(int64(size))).Perm(size)
4342
sort.Ints(x)
4443
y := x[size-(size/2):]
45-
b.StartTimer()
44+
b.ResetTimer()
4645
for i := 0; i < b.N; i++ {
4746
IntersectSorted(x, y)
4847
}

sorting/merge_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ func TestMergeInPlace(t *testing.T) {
3333
}
3434

3535
func benchMergeInPlace(b *testing.B, size int) {
36-
b.StopTimer()
3736
s := rand.NewSource(int64(size))
3837
x := rand.New(s).Perm(2 * size / 3)
3938
y := rand.New(s).Perm(size / 3)
4039
sort.Ints(x)
4140
sort.Ints(y)
42-
b.StartTimer()
41+
b.ResetTimer()
4342
for i := 0; i < b.N; i++ {
4443
MergeInPlace(x, y)
4544
}

0 commit comments

Comments
 (0)