Skip to content

Commit

Permalink
Bench command in multisubject mode subject format improvement
Browse files Browse the repository at this point in the history
When using nats bench in multisubject mode to generate messages in order to evaluate the amount of memory used by the indexes according to the number of subjects being stored in the stream it is more accurate if all the subjects have the same size. This achieves that by using padding 0 up to the length of the max number of subjects when creating the subjects.

Signed-off-by: Jean-Noël Moyne <[email protected]>
  • Loading branch information
jnmoyne committed Nov 1, 2024
1 parent cce064e commit c0f7939
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cli/bench_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ func (c *benchCmd) getPublishSubject(number int) string {
if c.multiSubjectMax == 0 {
return c.subject + "." + strconv.Itoa(number)
} else {
return c.subject + "." + strconv.Itoa(number%c.multiSubjectMax)
maxDigits := len(strconv.Itoa(c.multiSubjectMax))
format := fmt.Sprintf("%%0%dd", maxDigits)
return c.subject + "." + fmt.Sprintf(format, number%c.multiSubjectMax)
}
} else {
return c.subject
Expand Down

0 comments on commit c0f7939

Please sign in to comment.