MCPcopy
hub / github.com/jackc/pgx / benchmarkWriteNRowsViaMultiInsert

Function benchmarkWriteNRowsViaMultiInsert

bench_test.go:545–579  ·  view source on GitHub ↗
(b *testing.B, n int)

Source from the content-addressed store, hash-verified

543}
544
545func benchmarkWriteNRowsViaMultiInsert(b *testing.B, n int) {
546 conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))
547 defer closeConn(b, conn)
548
549 mustExec(b, conn, benchmarkWriteTableCreateSQL)
550 _, err := conn.Prepare(context.Background(), "insert_t", benchmarkWriteTableInsertSQL)
551 if err != nil {
552 b.Fatal(err)
553 }
554
555 for b.Loop() {
556 src := newBenchmarkWriteTableCopyFromSrc(n)
557
558 _, err := multiInsert(conn, "t",
559 []string{
560 "varchar_1",
561 "varchar_2",
562 "varchar_null_1",
563 "date_1",
564 "date_null_1",
565 "int4_1",
566 "int4_2",
567 "int4_null_1",
568 "tstz_1",
569 "tstz_2",
570 "bool_1",
571 "bool_2",
572 "bool_3",
573 },
574 src)
575 if err != nil {
576 b.Fatal(err)
577 }
578 }
579}
580
581func benchmarkWriteNRowsViaCopy(b *testing.B, n int) {
582 conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))

Calls 7

mustExecFunction · 0.85
multiInsertFunction · 0.85
mustConnectFunction · 0.70
mustParseConfigFunction · 0.70
closeConnFunction · 0.70
PrepareMethod · 0.65

Tested by

no test coverage detected