root.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2015 CoreOS, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package cmd
  15. import (
  16. "fmt"
  17. "os"
  18. "sync"
  19. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/cheggaaa/pb"
  20. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
  21. )
  22. // This represents the base command when called without any subcommands
  23. var RootCmd = &cobra.Command{
  24. Use: "benchmark",
  25. Short: "A low-level benchmark tool for etcd3",
  26. Long: `benchmark is a low-level benchmakr tool for etcd3.
  27. It uses gRPC client directly and does not depend on
  28. etcd client libray.
  29. `,
  30. }
  31. var (
  32. endpoints string
  33. totalConns uint
  34. totalClients uint
  35. bar *pb.ProgressBar
  36. results chan *result
  37. wg sync.WaitGroup
  38. )
  39. func init() {
  40. RootCmd.PersistentFlags().StringVar(&endpoints, "endpoint", "127.0.0.1:2378", "comma-separated gRPC endpoints")
  41. RootCmd.PersistentFlags().UintVar(&totalConns, "conns", 1, "Total number of gRPC connections")
  42. RootCmd.PersistentFlags().UintVar(&totalClients, "clients", 1, "Total number of gRPC clients")
  43. }
  44. func Execute() {
  45. if err := RootCmd.Execute(); err != nil {
  46. fmt.Println(err)
  47. os.Exit(-1)
  48. }
  49. }