* Update gocql version to v1.16.1 1. Update gocql to v1.16.1 2. Update golang to 1.25, since new gocql version requres it * Update golangci to 2.5.0 It is needed since 1.64.8 does not support golang 1.25. 1. Update golangci to 2.5.0 2. Migrate from golangci config v1 to v2 3. Integrate fieldaligment to golangci 4. Drop fieldaligment from Makefile 5. Address complaints
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
// 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/gocql/gocql"
|
|
|
|
"github.com/scylladb/gocqlx/v3"
|
|
)
|
|
|
|
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++ {
|
|
_, _, err := gocqlx.CompileNamedQuery(q)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func BenchmarkQueryxBindStruct(b *testing.B) {
|
|
q := gocqlx.Queryx{
|
|
Names: []string{"name", "age", "first", "last"},
|
|
Mapper: gocqlx.DefaultMapper,
|
|
Query: &gocql.Query{},
|
|
}
|
|
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"},
|
|
Mapper: gocqlx.DefaultMapper,
|
|
Query: &gocql.Query{},
|
|
}
|
|
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)
|
|
}
|
|
}
|