Fix string benchmark size; rename benchmarks; add map benchmark.

This commit is contained in:
Arseny Balobanov 2020-03-21 03:50:02 +03:00
parent 69abab266c
commit 3fe2f3144f

View file

@ -90,7 +90,7 @@ func (m *mockT) FailNow() {}
func (m *mockT) Helper() {} func (m *mockT) Helper() {}
func BenchmarkRequireEqual(b *testing.B) { func BenchmarkRequireEqualInt64(b *testing.B) {
t := &mockT{} t := &mockT{}
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
@ -98,7 +98,7 @@ func BenchmarkRequireEqual(b *testing.B) {
} }
} }
func BenchmarkTestifyRequireEqual(b *testing.B) { func BenchmarkTestifyRequireEqualInt64(b *testing.B) {
t := &mockT{} t := &mockT{}
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
@ -106,7 +106,7 @@ func BenchmarkTestifyRequireEqual(b *testing.B) {
} }
} }
func BenchmarkRequireStringsEqual(b *testing.B) { func BenchmarkRequireEqualString(b *testing.B) {
s1 := strings.Repeat("abacaba", 1024) s1 := strings.Repeat("abacaba", 1024)
s2 := strings.Repeat("abacaba", 1024) s2 := strings.Repeat("abacaba", 1024)
@ -117,9 +117,9 @@ func BenchmarkRequireStringsEqual(b *testing.B) {
} }
} }
func BenchmarkTestifyRequireStringsEqual(b *testing.B) { func BenchmarkTestifyRequireEqualString(b *testing.B) {
s1 := strings.Repeat("abacaba", 1024*8) s1 := strings.Repeat("abacaba", 1024)
s2 := strings.Repeat("abacaba", 1024*8) s2 := strings.Repeat("abacaba", 1024)
mockT := &mockT{} mockT := &mockT{}
b.ResetTimer() b.ResetTimer()
@ -127,3 +127,25 @@ func BenchmarkTestifyRequireStringsEqual(b *testing.B) {
require.Equal(mockT, s1, s2) require.Equal(mockT, s1, s2)
} }
} }
func BenchmarkRequireEqualMap(b *testing.B) {
m1 := map[string]string{"a": "b", "c": "d", "e": "f"}
m2 := map[string]string{"a": "b", "c": "d", "e": "f"}
mockT := &mockT{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
RequireEqual(mockT, m1, m2)
}
}
func BenchmarkTestifyRequireEqualMap(b *testing.B) {
m1 := map[string]string{"a": "b", "c": "d", "e": "f"}
m2 := map[string]string{"a": "b", "c": "d", "e": "f"}
mockT := &mockT{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
require.Equal(mockT, m1, m2)
}
}