Add full query decoding benchmarks

query-exec-mode
Jack Christensen 2021-08-28 14:07:13 -05:00
parent 11d351dd75
commit 2886673a3c
3 changed files with 1338 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
// Code generated by erb. DO NOT EDIT.
package pgtype_test
import (
"context"
"testing"
"github.com/jackc/pgtype/testutil"
"github.com/jackc/pgx/v4"
)
<%
[
["int4", ["int16", "int32", "int64", "uint64", "pgtype.Int4"], [[1, 1], [1, 10], [10, 1], [100, 10]]],
["numeric", ["int64", "float64", "pgtype.Numeric"], [[1, 1], [1, 10], [10, 1], [100, 10]]],
].each do |pg_type, go_types, rows_columns|
%>
<% go_types.each do |go_type| %>
<% rows_columns.each do |rows, columns| %>
<% [["Text", "pgx.TextFormatCode"], ["Binary", "pgx.BinaryFormatCode"]].each do |formatName, formatCode| %>
func BenchmarkQuery<%= formatName %>FormatDecode_PG_<%= pg_type %>_to_Go_<%= go_type.gsub(/\W/, "_") %>_<%= rows %>_rows_<%= columns %>_columns(b *testing.B) {
conn := testutil.MustConnectPgx(b)
defer testutil.MustCloseContext(b, conn)
b.ResetTimer()
var v [<%= columns %>]<%= go_type %>
for i := 0; i < b.N; i++ {
_, err := conn.QueryFunc(
context.Background(),
`select <% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>n::<%= pg_type %> + <%= col_idx%><% end %> from generate_series(1, <%= rows %>) n`,
[]interface{}{pgx.QueryResultFormats{<%= formatCode %>}},
[]interface{}{<% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>&v[<%= col_idx%>]<% end %>},
func(pgx.QueryFuncRow) error { return nil },
)
if err != nil {
b.Fatal(err)
}
}
}
<% end %>
<% end %>
<% end %>
<% end %>

View File

@ -0,0 +1,2 @@
erb integration_benchmark_test.go.erb > integration_benchmark_test.go
goimports -w integration_benchmark_test.go