2
0

Remove 2 mallocs from query path

This commit is contained in:
Jack Christensen
2019-05-04 08:55:05 -05:00
parent 7558b8d05f
commit 85ddbfeeee
4 changed files with 48 additions and 4 deletions
+24
View File
@@ -13,6 +13,30 @@ import (
"github.com/jackc/pgx/v4"
)
func BenchmarkMinimalPreparedSelect(b *testing.B) {
conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))
defer closeConn(b, conn)
_, err := conn.Prepare(context.Background(), "ps1", "select $1::int8")
if err != nil {
b.Fatal(err)
}
var n int64
b.ResetTimer()
for i := 0; i < b.N; i++ {
err = conn.QueryRow(context.Background(), "ps1", int64(i)).Scan(&n)
if err != nil {
b.Fatal(err)
}
if n != int64(i) {
b.Fatalf("expected %d, got %d", i, n)
}
}
}
func BenchmarkPointerPointerWithNullValues(b *testing.B) {
conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))
defer closeConn(b, conn)