forked from scylladb/gocqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queryx_bench_test.go
52 lines (46 loc) · 1.06 KB
/
queryx_bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (C) 2017 ScyllaDB
// Use of this source code is governed by a ALv2-style
// license that can be found in the LICENSE file.
package gocqlx_test
import (
"testing"
"github.com/scylladb/gocqlx/v2"
)
func BenchmarkCompileNamedQuery(b *testing.B) {
q := []byte("INSERT INTO cycling.cyclist_name (id, user_uuid, firstname, stars) VALUES (:id, :user_uuid, :firstname, :stars)")
b.ResetTimer()
for i := 0; i < b.N; i++ {
gocqlx.CompileNamedQuery(q)
}
}
func BenchmarkQueryxBindStruct(b *testing.B) {
q := gocqlx.Queryx{
Names: []string{"name", "age", "first", "last"},
}
type t struct {
Name string
Age int
First string
Last string
}
am := t{"Jason Moiron", 30, "Jason", "Moiron"}
b.ResetTimer()
for i := 0; i < b.N; i++ {
q.BindStruct(am)
}
}
func BenchmarkBindMap(b *testing.B) {
q := gocqlx.Queryx{
Names: []string{"name", "age", "first", "last"},
}
am := map[string]interface{}{
"name": "Jason Moiron",
"age": 30,
"first": "Jason",
"last": "Moiron",
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
q.BindMap(am)
}
}