MCPcopy
hub / github.com/go-sql-driver/mysql / BenchmarkInterpolation

Function BenchmarkInterpolation

benchmark_test.go:228–257  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

226}
227
228func BenchmarkInterpolation(b *testing.B) {
229 mc := &mysqlConn{
230 cfg: &Config{
231 InterpolateParams: true,
232 Loc: time.UTC,
233 },
234 maxAllowedPacket: maxPacketSize,
235 maxWriteSize: maxPacketSize - 1,
236 buf: newBuffer(),
237 }
238
239 args := []driver.Value{
240 int64(42424242),
241 float64(math.Pi),
242 false,
243 time.Unix(1423411542, 807015000),
244 []byte("bytes containing special chars ' \" \a \x00"),
245 "string containing special chars ' \" \a \x00",
246 }
247 q := "SELECT ?, ?, ?, ?, ?, ?"
248
249 b.ReportAllocs()
250
251 for b.Loop() {
252 _, err := mc.interpolateParams(q, args)
253 if err != nil {
254 b.Fatal(err)
255 }
256 }
257}
258
259func benchmarkQueryContext(b *testing.B, db *sql.DB, p int) {
260 ctx, cancel := context.WithCancel(context.Background())

Callers

nothing calls this directly

Calls 2

interpolateParamsMethod · 0.95
newBufferFunction · 0.85

Tested by

no test coverage detected