Add full query decoding benchmarks
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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 %>
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
erb integration_benchmark_test.go.erb > integration_benchmark_test.go
|
||||
goimports -w integration_benchmark_test.go
|
||||
Reference in New Issue
Block a user