File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 8
8
9
9
var (
10
10
// dsn from driver_test.go
11
- sample = []byte (strings .Repeat ("0123456789abcdef" , 1024 * 1024 ))
11
+ sample = []byte (strings .Repeat ("0123456789abcdef" , 1024 * 1024 ))
12
+ min , max = 16 , len (sample )
12
13
)
13
14
14
15
func BenchmarkRoundtripText (b * testing.B ) {
@@ -19,7 +20,10 @@ func BenchmarkRoundtripText(b *testing.B) {
19
20
defer db .Close ()
20
21
var result string
21
22
for i := 0 ; i < b .N ; i ++ {
22
- length := 16 + i % (4 * b .N )
23
+ length := min + i
24
+ if length > max {
25
+ length = max
26
+ }
23
27
test := string (sample [0 :length ])
24
28
rows , err := db .Query ("SELECT \" " + test + "\" " )
25
29
if err != nil {
@@ -54,7 +58,10 @@ func BenchmarkRoundtripPrepared(b *testing.B) {
54
58
b .Fatalf ("crashed" )
55
59
}
56
60
for i := 0 ; i < b .N ; i ++ {
57
- length := 16 + i % (4 * b .N )
61
+ length := min + i
62
+ if length > max {
63
+ length = max
64
+ }
58
65
test := string (sample [0 :length ])
59
66
rows , err := stmt .Query (test )
60
67
if err != nil {
You can’t perform that action at this time.
0 commit comments