-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathintegration_benchmark_test.go.erb
43 lines (39 loc) · 1.26 KB
/
integration_benchmark_test.go.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Code generated by erb. DO NOT EDIT.
package uuid_test
import (
"context"
"testing"
"github.com/jackc/pgx/v5/pgtype/testutil"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5"
"github.com/gofrs/uuid/v5"
pgxuuid "github.com/jackc/pgx-gofrs-uuid"
)
<%
[
[["pgtype.UUID","uuid.UUID", "uuid.NullUUID"], [[1, 1], [1, 10], [10, 1], [100, 10]]],
].each do |go_types, rows_columns|
%>
<% go_types.each do |go_type| %>
<% rows_columns.each do |rows, columns| %>
func BenchmarkQueryDecode_PG_UUID_to_Go_<%= go_type.gsub(/\W/, "_") %>_<%= rows %>_rows_<%= columns %>_columns(b *testing.B) {
defaultConnTestRunner.RunTest(context.Background(), b, func(ctx context.Context, _ testing.TB, conn *pgx.Conn) {
b.ResetTimer()
var v [<%= columns %>]<%= go_type %>
for i := 0; i < b.N; i++ {
_, err := conn.QueryFunc(
ctx,
`select <% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>gen_random_uuid()<% end %> from generate_series(1, <%= rows %>) n`,
nil,
[]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 %>