| 191 | } |
| 192 | |
| 193 | func 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 | |
| 228 | func BenchmarkInterpolation(b *testing.B) { |
| 229 | mc := &mysqlConn{ |