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/bench: fix bench progress bar #4388

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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
19 changes: 7 additions & 12 deletions cmd/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,6 @@ func bench(ctx *cli.Context) error {
dropCaches()
bm.colorful = utils.SupportANSIColor(os.Stdout.Fd())
progress := utils.NewProgress(false)
if b := bm.big; b != nil {
total := int64(bm.threads * b.fcount * b.bcount)
b.wbar = progress.AddCountBar("Write big blocks", total)
b.rbar = progress.AddCountBar("Read big blocks", total)
}
if s := bm.small; s != nil {
total := int64(bm.threads * s.fcount * s.bcount)
s.wbar = progress.AddCountBar("Write small blocks", total)
s.rbar = progress.AddCountBar("Read small blocks", total)
s.sbar = progress.AddCountBar("Stat small files", int64(bm.threads*s.fcount))
}

/* --- Run Benchmark --- */
var stats map[string]float64
if mp != "" {
Expand All @@ -383,6 +371,8 @@ func bench(ctx *cli.Context) error {
var result [][]string
result = append(result, []string{"ITEM", "VALUE", "COST"})
if b := bm.big; b != nil {
total := int64(bm.threads * b.fcount * b.bcount)
b.wbar = progress.AddCountBar("Write big blocks", total)
cost := b.run("write")
b.wbar.Done()
line := make([]string, 3)
Expand All @@ -393,6 +383,7 @@ func bench(ctx *cli.Context) error {
result = append(result, line)
dropCaches()

b.rbar = progress.AddCountBar("Read big blocks", total)
cost = b.run("read")
b.rbar.Done()
line = make([]string, 3)
Expand All @@ -403,6 +394,8 @@ func bench(ctx *cli.Context) error {
result = append(result, line)
}
if s := bm.small; s != nil {
total := int64(bm.threads * s.fcount * s.bcount)
s.wbar = progress.AddCountBar("Write small blocks", total)
cost := s.run("write")
s.wbar.Done()
line := make([]string, 3)
Expand All @@ -413,6 +406,7 @@ func bench(ctx *cli.Context) error {
result = append(result, line)
dropCaches()

s.rbar = progress.AddCountBar("Read small blocks", total)
cost = s.run("read")
s.rbar.Done()
line = make([]string, 3)
Expand All @@ -423,6 +417,7 @@ func bench(ctx *cli.Context) error {
result = append(result, line)
dropCaches()

s.sbar = progress.AddCountBar("Stat small files", int64(bm.threads*s.fcount))
cost = s.run("stat")
s.sbar.Done()
line = make([]string, 3)
Expand Down
Loading