| 157 | } |
| 158 | |
| 159 | func BenchmarkRoundtripTxt(b *testing.B) { |
| 160 | sample, min, max := initRoundtripBenchmarks() |
| 161 | sampleString := string(sample) |
| 162 | tb := (*TB)(b) |
| 163 | db := tb.checkDB(sql.Open(driverNameTest, dsn)) |
| 164 | defer db.Close() |
| 165 | |
| 166 | b.ReportAllocs() |
| 167 | |
| 168 | var result string |
| 169 | for i := 0; b.Loop(); i++ { |
| 170 | length := min + i |
| 171 | if length > max { |
| 172 | length = max |
| 173 | } |
| 174 | test := sampleString[0:length] |
| 175 | rows := tb.checkRows(db.Query(`SELECT "` + test + `"`)) |
| 176 | if !rows.Next() { |
| 177 | rows.Close() |
| 178 | b.Fatalf("crashed") |
| 179 | } |
| 180 | err := rows.Scan(&result) |
| 181 | if err != nil { |
| 182 | rows.Close() |
| 183 | b.Fatalf("crashed") |
| 184 | } |
| 185 | if result != test { |
| 186 | rows.Close() |
| 187 | b.Errorf("mismatch") |
| 188 | } |
| 189 | rows.Close() |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | func BenchmarkRoundtripBin(b *testing.B) { |
| 194 | sample, min, max := initRoundtripBenchmarks() |