diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-04-16 05:37:14 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-04-16 08:37:14 -0400 |
commit | 6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch) | |
tree | 3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/go-sql-driver/mysql/benchmark_go18_test.go | |
parent | bf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff) | |
download | chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2 chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip |
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/go-sql-driver/mysql/benchmark_go18_test.go')
-rw-r--r-- | vendor/github.com/go-sql-driver/mysql/benchmark_go18_test.go | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/vendor/github.com/go-sql-driver/mysql/benchmark_go18_test.go b/vendor/github.com/go-sql-driver/mysql/benchmark_go18_test.go deleted file mode 100644 index d6a7e9d6e..000000000 --- a/vendor/github.com/go-sql-driver/mysql/benchmark_go18_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// Go MySQL Driver - A MySQL-Driver for Go's database/sql package -// -// Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved. -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this file, -// You can obtain one at http://mozilla.org/MPL/2.0/. - -// +build go1.8 - -package mysql - -import ( - "context" - "database/sql" - "fmt" - "runtime" - "testing" -) - -func benchmarkQueryContext(b *testing.B, db *sql.DB, p int) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - db.SetMaxIdleConns(p * runtime.GOMAXPROCS(0)) - - tb := (*TB)(b) - stmt := tb.checkStmt(db.PrepareContext(ctx, "SELECT val FROM foo WHERE id=?")) - defer stmt.Close() - - b.SetParallelism(p) - b.ReportAllocs() - b.ResetTimer() - b.RunParallel(func(pb *testing.PB) { - var got string - for pb.Next() { - tb.check(stmt.QueryRow(1).Scan(&got)) - if got != "one" { - b.Fatalf("query = %q; want one", got) - } - } - }) -} - -func BenchmarkQueryContext(b *testing.B) { - db := initDB(b, - "DROP TABLE IF EXISTS foo", - "CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))", - `INSERT INTO foo VALUES (1, "one")`, - `INSERT INTO foo VALUES (2, "two")`, - ) - defer db.Close() - for _, p := range []int{1, 2, 3, 4} { - b.Run(fmt.Sprintf("%d", p), func(b *testing.B) { - benchmarkQueryContext(b, db, p) - }) - } -} - -func benchmarkExecContext(b *testing.B, db *sql.DB, p int) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - db.SetMaxIdleConns(p * runtime.GOMAXPROCS(0)) - - tb := (*TB)(b) - stmt := tb.checkStmt(db.PrepareContext(ctx, "DO 1")) - defer stmt.Close() - - b.SetParallelism(p) - b.ReportAllocs() - b.ResetTimer() - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - if _, err := stmt.ExecContext(ctx); err != nil { - b.Fatal(err) - } - } - }) -} - -func BenchmarkExecContext(b *testing.B) { - db := initDB(b, - "DROP TABLE IF EXISTS foo", - "CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))", - `INSERT INTO foo VALUES (1, "one")`, - `INSERT INTO foo VALUES (2, "two")`, - ) - defer db.Close() - for _, p := range []int{1, 2, 3, 4} { - b.Run(fmt.Sprintf("%d", p), func(b *testing.B) { - benchmarkQueryContext(b, db, p) - }) - } -} |