testing: benchmarks moved to separate files

This commit is contained in:
Michał Matczuk
2018-05-22 16:37:02 +02:00
parent 444d07da6a
commit a8febbc71e
17 changed files with 169 additions and 108 deletions

View File

@@ -2,14 +2,11 @@
// Use of this source code is governed by a ALv2-style
// license that can be found in the LICENSE file.
// +build !integration
package gocqlx
import (
"testing"
"github.com/gocql/gocql"
"github.com/google/go-cmp/cmp"
)
@@ -64,14 +61,6 @@ func TestCompileQuery(t *testing.T) {
}
}
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++ {
CompileNamedQuery(q)
}
}
func TestBindStruct(t *testing.T) {
v := &struct {
Name string
@@ -132,21 +121,6 @@ func TestBindStruct(t *testing.T) {
})
}
func BenchmarkBindStruct(b *testing.B) {
q := Query(&gocql.Query{}, []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 TestBindMap(t *testing.T) {
v := map[string]interface{}{
"name": "name",
@@ -175,20 +149,3 @@ func TestBindMap(t *testing.T) {
}
})
}
func BenchmarkBindMap(b *testing.B) {
q := Queryx{
Query: &gocql.Query{},
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)
}
}