MCPcopy
hub / github.com/jmoiron/sqlx / BenchmarkBindSpeed

Function BenchmarkBindSpeed

bind_test.go:43–79  ·  view source on GitHub ↗

* sync.Map implementation: goos: linux goarch: amd64 pkg: github.com/jmoiron/sqlx BenchmarkBindSpeed/old-4 100000000 11.0 ns/op BenchmarkBindSpeed/new-4 24575726 50.8 ns/op async.Value map implementation: goos: linux goarch: amd64 pkg: github.com/jmoiron/sqlx Be

(b *testing.B)

Source from the content-addressed store, hash-verified

41*/
42
43func BenchmarkBindSpeed(b *testing.B) {
44 testDrivers := []string{
45 "postgres", "pgx", "mysql", "sqlite3", "ora", "sqlserver",
46 }
47
48 b.Run("old", func(b *testing.B) {
49 b.StopTimer()
50 var seq []int
51 for i := 0; i < b.N; i++ {
52 seq = append(seq, rand.Intn(len(testDrivers)))
53 }
54 b.StartTimer()
55 for i := 0; i < b.N; i++ {
56 s := oldBindType(testDrivers[seq[i]])
57 if s == UNKNOWN {
58 b.Error("unknown driver")
59 }
60 }
61
62 })
63
64 b.Run("new", func(b *testing.B) {
65 b.StopTimer()
66 var seq []int
67 for i := 0; i < b.N; i++ {
68 seq = append(seq, rand.Intn(len(testDrivers)))
69 }
70 b.StartTimer()
71 for i := 0; i < b.N; i++ {
72 s := BindType(testDrivers[seq[i]])
73 if s == UNKNOWN {
74 b.Error("unknown driver")
75 }
76 }
77
78 })
79}

Callers

nothing calls this directly

Calls 3

oldBindTypeFunction · 0.85
BindTypeFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected