From 1e24b15b88c87d4c77a4aa62ae83a33f030fe3b1 Mon Sep 17 00:00:00 2001 From: zhijian Date: Wed, 6 Nov 2024 10:42:17 +0800 Subject: [PATCH] fix --- cmd/objbench.go | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/cmd/objbench.go b/cmd/objbench.go index d4f8577567c3..fa9712ed838b 100644 --- a/cmd/objbench.go +++ b/cmd/objbench.go @@ -119,7 +119,7 @@ var ( type warning error var groupName string -var bCount, sCount int +var listCount, bCount, sCount int func objbench(ctx *cli.Context) error { setup(ctx, 1) @@ -171,6 +171,10 @@ func objbench(ctx *cli.Context) error { }() bCount = int(math.Ceil(float64(fsize) / float64(bSize))) sCount = int(ctx.Uint("small-objects")) + listCount = sCount + bCount + if listCount > 1000 { + listCount = 1000 + } threads := int(ctx.Uint("threads")) colorful := utils.SupportANSIColor(os.Stdout.Fd()) progress := utils.NewProgress(false) @@ -270,10 +274,6 @@ func objbench(ctx *cli.Context) error { getResult: func(cost float64) []string { line := []string{"", nspt, nspt} if cost > 0 { - listCount := sCount + bCount - if listCount > 1000 { - listCount = 1000 - } line[1], line[2] = colorize("list", float64(listCount)*float64(threads)/cost, float64(threads)*cost*10, 2, colorful) line[1] += " objects/s" line[2] += fmt.Sprintf(" ms/ %d objects", listCount) @@ -282,12 +282,12 @@ func objbench(ctx *cli.Context) error { }, }, { name: "head", - count: sCount, + count: sCount + bCount, title: "head objects", getResult: func(cost float64) []string { line := []string{"", nspt, nspt} if cost > 0 { - line[1], line[2] = colorize("head", float64(sCount)/cost, float64(threads)*cost*1000/float64(sCount), 1, colorful) + line[1], line[2] = colorize("head", float64(sCount+bCount)/cost, float64(threads)*cost*1000/float64(sCount+bCount), 1, colorful) line[1] += " objects/s" line[2] += " ms/object" } @@ -295,12 +295,12 @@ func objbench(ctx *cli.Context) error { }, }, { name: "chtimes", - count: sCount, + count: sCount + bCount, title: "update mtime", getResult: func(cost float64) []string { line := []string{"", nspt, nspt} if cost > 0 { - line[1], line[2] = colorize("chtimes", float64(sCount)/cost, float64(threads)*cost*1000/float64(sCount), 1, colorful) + line[1], line[2] = colorize("chtimes", float64(sCount+bCount)/cost, float64(threads)*cost*1000/float64(sCount+bCount), 1, colorful) line[1] += " objects/s" line[2] += " ms/object" } @@ -308,12 +308,12 @@ func objbench(ctx *cli.Context) error { }, }, { name: "chmod", - count: sCount, + count: sCount + bCount, title: "change permissions", getResult: func(cost float64) []string { line := []string{"", nspt, nspt} if cost > 0 { - line[1], line[2] = colorize("chmod", float64(sCount)/cost, float64(threads)*cost*1000/float64(sCount), 1, colorful) + line[1], line[2] = colorize("chmod", float64(sCount+bCount)/cost, float64(threads)*cost*1000/float64(sCount+bCount), 1, colorful) line[1] += " objects/s" line[2] += " ms/object" } @@ -321,12 +321,12 @@ func objbench(ctx *cli.Context) error { }, }, { name: "chown", - count: sCount, + count: sCount + bCount, title: "change owner/group", getResult: func(cost float64) []string { line := []string{"", nspt, nspt} if cost > 0 { - line[1], line[2] = colorize("chown", float64(sCount)/cost, float64(threads)*cost*1000/float64(sCount), 1, colorful) + line[1], line[2] = colorize("chown", float64(sCount+bCount)/cost, float64(threads)*cost*1000/float64(sCount+bCount), 1, colorful) line[1] += " objects/s" line[2] += " ms/object" } @@ -482,10 +482,6 @@ func (bm *benchMarkObj) run(api apiInfo) []string { count := api.count var bar *utils.Bar if api.name == "list" { - listCount := bCount + sCount - if bCount+sCount > 1000 { - listCount = 1000 - } bar = bm.progressBar.AddCountBar(api.title, int64(listCount)*int64(count)) } else { bar = bm.progressBar.AddCountBar(api.title, int64(count)) @@ -504,7 +500,7 @@ func (bm *benchMarkObj) run(api apiInfo) []string { err = e } if api.name == "list" { - bar.IncrInt64(int64(bCount + sCount)) + bar.IncrInt64(int64(listCount)) } else { bar.Increment() }