Skip to content

Commit

Permalink
remove the unnecessary call to ResetTimer and StopTimer (#6185)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanvc committed Apr 14, 2023
1 parent fe72db9 commit d90621f
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions benchmark/primitives/code_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,49 +87,39 @@ func (i codeBench) StringUsingMap() string {
}

func BenchmarkCodeStringStringer(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
c := codeBench(uint32(i % 17))
_ = c.String()
}
b.StopTimer()
}

func BenchmarkCodeStringMap(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
c := codeBench(uint32(i % 17))
_ = c.StringUsingMap()
}
b.StopTimer()
}

// codes.Code.String() does a switch.
func BenchmarkCodeStringSwitch(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
c := codes.Code(uint32(i % 17))
_ = c.String()
}
b.StopTimer()
}

// Testing all codes (0<=c<=16) and also one overflow (17).
func BenchmarkCodeStringStringerWithOverflow(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
c := codeBench(uint32(i % 18))
_ = c.String()
}
b.StopTimer()
}

// Testing all codes (0<=c<=16) and also one overflow (17).
func BenchmarkCodeStringSwitchWithOverflow(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
c := codes.Code(uint32(i % 18))
_ = c.String()
}
b.StopTimer()
}

0 comments on commit d90621f

Please sign in to comment.