From 8faa1f5096ecc4a0cb2fd18f0deb522b0e670182 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 16 May 2020 18:43:22 -0500 Subject: [PATCH] Fix off by one error with number of rows benchmark --- bench_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bench_test.go b/bench_test.go index ae66134d..98280922 100644 --- a/bench_test.go +++ b/bench_test.go @@ -993,7 +993,7 @@ func BenchmarkSelectRowsScanSimple(b *testing.B) { b.Run(fmt.Sprintf("%d rows", rowCount), func(b *testing.B) { br := &BenchRowSimple{} for i := 0; i < b.N; i++ { - rows, err := conn.Query(context.Background(), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100000, 100000 + $1) n", rowCount) + rows, err := conn.Query(context.Background(), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100001, 100000 + $1) n", rowCount) if err != nil { b.Fatal(err) } @@ -1031,7 +1031,7 @@ func BenchmarkSelectRowsScanStringBytes(b *testing.B) { b.Run(fmt.Sprintf("%d rows", rowCount), func(b *testing.B) { br := &BenchRowStringBytes{} for i := 0; i < b.N; i++ { - rows, err := conn.Query(context.Background(), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100000, 100000 + $1) n", rowCount) + rows, err := conn.Query(context.Background(), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100001, 100000 + $1) n", rowCount) if err != nil { b.Fatal(err) } @@ -1081,7 +1081,7 @@ func BenchmarkSelectRowsScanDecoder(b *testing.B) { for i := 0; i < b.N; i++ { rows, err := conn.Query( context.Background(), - "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100000, 100000 + $1) n", + "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100001, 100000 + $1) n", pgx.QueryResultFormats{format.code}, rowCount, ) @@ -1113,7 +1113,7 @@ func BenchmarkSelectRowsExplicitBinaryDecoding(b *testing.B) { b.Run(fmt.Sprintf("%d rows", rowCount), func(b *testing.B) { br := &BenchRowDecoder{} for i := 0; i < b.N; i++ { - rows, err := conn.Query(context.Background(), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100000, 100000 + $1) n", rowCount) + rows, err := conn.Query(context.Background(), "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100001, 100000 + $1) n", rowCount) if err != nil { b.Fatal(err) } @@ -1179,7 +1179,7 @@ func BenchmarkSelectRowsPgConnExecText(b *testing.B) { for _, rowCount := range rowCounts { b.Run(fmt.Sprintf("%d rows", rowCount), func(b *testing.B) { for i := 0; i < b.N; i++ { - mrr := conn.PgConn().Exec(context.Background(), fmt.Sprintf("select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100000, 100000 + %d) n", rowCount)) + mrr := conn.PgConn().Exec(context.Background(), fmt.Sprintf("select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100001, 100000 + %d) n", rowCount)) for mrr.NextResult() { rr := mrr.ResultReader() for rr.NextRow() { @@ -1216,7 +1216,7 @@ func BenchmarkSelectRowsPgConnExecParams(b *testing.B) { for i := 0; i < b.N; i++ { rr := conn.PgConn().ExecParams( context.Background(), - "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100000, 100000 + $1) n", + "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100001, 100000 + $1) n", [][]byte{[]byte(strconv.FormatInt(rowCount, 10))}, nil, nil, @@ -1243,7 +1243,7 @@ func BenchmarkSelectRowsPgConnExecPrepared(b *testing.B) { rowCounts := getSelectRowsCounts(b) - _, err := conn.PgConn().Prepare(context.Background(), "ps1", "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100000, 100000 + $1) n", nil) + _, err := conn.PgConn().Prepare(context.Background(), "ps1", "select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, now() from generate_series(100001, 100000 + $1) n", nil) if err != nil { b.Fatal(err) }