From 70d90f50992e7002eeb50350e24b5622ad45bdef Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Tue, 17 Dec 2024 22:30:07 +0530 Subject: [PATCH] test: some refactor Signed-off-by: Harshit Gangal --- .../endtoend/transaction/benchmark/bench_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/go/test/endtoend/transaction/benchmark/bench_test.go b/go/test/endtoend/transaction/benchmark/bench_test.go index a7f108afbcb..a42c9bca9c1 100644 --- a/go/test/endtoend/transaction/benchmark/bench_test.go +++ b/go/test/endtoend/transaction/benchmark/bench_test.go @@ -100,6 +100,13 @@ func cleanup(b *testing.B) { // BenchmarkTwoPCCommit benchmarks the performance of a two-phase commit transaction // with varying numbers of inserts. +// Recommended run options: +/* +export ver=v1 p=~/path && go test \ +-run '^$' -bench '^BenchmarkTwoPCCommit' \ +-benchtime 3s -count 6 -cpu 8 +| tee $p/${ver}.txt +*/ func BenchmarkTwoPCCommit(b *testing.B) { // Pre-generate 100 random strings const sampleSize = 100 @@ -119,10 +126,9 @@ func BenchmarkTwoPCCommit(b *testing.B) { // Incremental id for inserts id := 1 - for _, commitMode := range []string{"multi", "twopc"} { - - for _, tc := range testCases { - conn, done := start(b) + for _, tc := range testCases { + for _, commitMode := range []string{"twopc", "multi"} { + conn, _ := start(b) _, err := conn.ExecuteFetch(fmt.Sprintf("set transaction_mode = %s", commitMode), 0, false) if err != nil { b.Fatal(err) @@ -151,7 +157,7 @@ func BenchmarkTwoPCCommit(b *testing.B) { } } }) - done() + conn.Close() } } }