Skip to content

Commit

Permalink
Merge pull request etcd-io#16196 from fuweid/benchmark-support-range-…
Browse files Browse the repository at this point in the history
…countonly

tools/benchmark: support --count-only for range
  • Loading branch information
ahrtr authored Jul 12, 2023
2 parents 5216eea + 70c8f04 commit 930dbbc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/benchmark/cmd/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
rangeTotal int
rangeConsistency string
rangeLimit int64
rangeCountOnly bool
)

func init() {
Expand All @@ -50,6 +51,7 @@ func init() {
rangeCmd.Flags().IntVar(&rangeTotal, "total", 10000, "Total number of range requests")
rangeCmd.Flags().StringVar(&rangeConsistency, "consistency", "l", "Linearizable(l) or Serializable(s)")
rangeCmd.Flags().Int64Var(&rangeLimit, "limit", 0, "Maximum number of results to return from range request (0 is no limit)")
rangeCmd.Flags().BoolVar(&rangeCountOnly, "count-only", false, "Only returns the count of keys")
}

func rangeFunc(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -103,6 +105,9 @@ func rangeFunc(cmd *cobra.Command, args []string) {
go func() {
for i := 0; i < rangeTotal; i++ {
opts := []v3.OpOption{v3.WithRange(end), v3.WithLimit(rangeLimit)}
if rangeCountOnly {
opts = append(opts, v3.WithCountOnly())
}
if rangeConsistency == "s" {
opts = append(opts, v3.WithSerializable())
}
Expand Down

0 comments on commit 930dbbc

Please sign in to comment.