Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Nov 6, 2024
1 parent d790a07 commit 1e24b15
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions cmd/objbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -282,51 +282,51 @@ 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"
}
return line
},
}, {
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"
}
return line
},
}, {
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"
}
return line
},
}, {
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"
}
Expand Down Expand Up @@ -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))
Expand All @@ -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()
}
Expand Down

0 comments on commit 1e24b15

Please sign in to comment.