Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/bbolt: write bench results to stdout #767

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/bbolt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,11 +1056,11 @@ func (cmd *benchCommand) Run(args ...string) error {
benchWriteName := "BenchmarkWrite"
benchReadName := "BenchmarkRead"
maxLen := max(len(benchReadName), len(benchWriteName))
printGoBenchResult(cmd.Stderr, writeResults, maxLen, benchWriteName)
printGoBenchResult(cmd.Stderr, readResults, maxLen, benchReadName)
printGoBenchResult(cmd.Stdout, writeResults, maxLen, benchWriteName)
printGoBenchResult(cmd.Stdout, readResults, maxLen, benchReadName)
} else {
fmt.Fprintf(cmd.Stderr, "# Write\t%v(ops)\t%v\t(%v/op)\t(%v op/sec)\n", writeResults.CompletedOps(), writeResults.Duration(), writeResults.OpDuration(), writeResults.OpsPerSecond())
fmt.Fprintf(cmd.Stderr, "# Read\t%v(ops)\t%v\t(%v/op)\t(%v op/sec)\n", readResults.CompletedOps(), readResults.Duration(), readResults.OpDuration(), readResults.OpsPerSecond())
fmt.Fprintf(cmd.Stdout, "# Write\t%v(ops)\t%v\t(%v/op)\t(%v op/sec)\n", writeResults.CompletedOps(), writeResults.Duration(), writeResults.OpDuration(), writeResults.OpsPerSecond())
fmt.Fprintf(cmd.Stdout, "# Read\t%v(ops)\t%v\t(%v/op)\t(%v op/sec)\n", readResults.CompletedOps(), readResults.Duration(), readResults.OpDuration(), readResults.OpsPerSecond())
}
fmt.Fprintln(cmd.Stderr, "")

Expand Down
5 changes: 3 additions & 2 deletions cmd/bbolt/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ func TestBenchCommand_Run(t *testing.T) {
}

stderr := m.Stderr.String()
stdout := m.Stdout.String()
if !strings.Contains(stderr, "starting write benchmark.") || !strings.Contains(stderr, "starting read benchmark.") {
t.Fatal(fmt.Errorf("benchmark result does not contain read/write start output:\n%s", stderr))
}
Expand All @@ -492,8 +493,8 @@ func TestBenchCommand_Run(t *testing.T) {
t.Fatal(fmt.Errorf("found iter mismatch in stdout:\n%s", stderr))
}

if !strings.Contains(stderr, "# Write") || !strings.Contains(stderr, "# Read") {
t.Fatal(fmt.Errorf("benchmark result does not contain read/write output:\n%s", stderr))
if !strings.Contains(stdout, "# Write") || !strings.Contains(stdout, "# Read") {
t.Fatal(fmt.Errorf("benchmark result does not contain read/write output:\n%s", stdout))
}
})
}
Expand Down