Skip to content

Commit

Permalink
test: some refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Dec 17, 2024
1 parent e8fafcc commit 70d90f5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions go/test/endtoend/transaction/benchmark/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -151,7 +157,7 @@ func BenchmarkTwoPCCommit(b *testing.B) {
}
}
})
done()
conn.Close()
}
}
}
Expand Down

0 comments on commit 70d90f5

Please sign in to comment.