Skip to content

Commit e92e74b

Browse files
committed
Inline error check
Previously, we were benchmarking the assert.NoError call, which isn't particularly cheap.
1 parent a0d72bc commit e92e74b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

reader_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@ func BenchmarkLookup(b *testing.B) {
645645
for i := 0; i < b.N; i++ {
646646
randomIPv4Address(r, ip)
647647
err = db.Lookup(ip, &result)
648-
assert.NoError(b, err)
648+
if err != nil {
649+
b.Error(err)
650+
}
649651
}
650652
assert.NoError(b, db.Close(), "error on close")
651653
}
@@ -667,7 +669,9 @@ func BenchmarkCountryCode(b *testing.B) {
667669
for i := 0; i < b.N; i++ {
668670
randomIPv4Address(r, ip)
669671
err = db.Lookup(ip, &result)
670-
assert.NoError(b, err)
672+
if err != nil {
673+
b.Error(err)
674+
}
671675
}
672676
assert.NoError(b, db.Close(), "error on close")
673677
}

0 commit comments

Comments
 (0)