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

Function BenchmarkRoundtripBin

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

Source from the content-addressed store, hash-verified

191}
192
193func BenchmarkRoundtripBin(b *testing.B) {
194 sample, min, max := initRoundtripBenchmarks()
195 tb := (*TB)(b)
196 db := tb.checkDB(sql.Open(driverNameTest, dsn))
197 defer db.Close()
198 stmt := tb.checkStmt(db.Prepare("SELECT ?"))
199 defer stmt.Close()
200
201 b.ReportAllocs()
202
203 var result sql.RawBytes
204 for i := 0; b.Loop(); i++ {
205 length := min + i
206 if length > max {
207 length = max
208 }
209 test := sample[0:length]
210 rows := tb.checkRows(stmt.Query(test))
211 if !rows.Next() {
212 rows.Close()
213 b.Fatalf("crashed")
214 }
215 err := rows.Scan(&result)
216 if err != nil {
217 rows.Close()
218 b.Fatalf("crashed")
219 }
220 if !bytes.Equal(result, test) {
221 rows.Close()
222 b.Errorf("mismatch")
223 }
224 rows.Close()
225 }
226}
227
228func BenchmarkInterpolation(b *testing.B) {
229 mc := &mysqlConn{

Callers

nothing calls this directly

Calls 10

initRoundtripBenchmarksFunction · 0.85
checkDBMethod · 0.80
OpenMethod · 0.80
checkStmtMethod · 0.80
PrepareMethod · 0.80
checkRowsMethod · 0.80
ScanMethod · 0.80
CloseMethod · 0.45
QueryMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected