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

Function BenchmarkRoundtripTxt

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

Source from the content-addressed store, hash-verified

157}
158
159func 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
193func BenchmarkRoundtripBin(b *testing.B) {
194 sample, min, max := initRoundtripBenchmarks()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected