Skip to content
Snippets Groups Projects
Commit 8afba7a8 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add benchmark subcommand with appropriate flags

parent 9333ec2f
No related branches found
No related tags found
No related merge requests found
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var benchBatchSize uint64
var nodeCount int
var iterations int
func init() {
benchmarkCmd.Flags().Uint64VarP(&benchBatchSize, "batch", "b", 1,
"Batch size to use for node server rounds")
benchmarkCmd.Flags().IntVarP(&nodeCount, "numnodes", "n", 1,
"Number of nodes for the benchmark")
benchmarkCmd.Flags().IntVarP(&iterations, "iterations", "i", 100,
"Number of times to iterate the benchmark")
rootCmd.AddCommand(benchmarkCmd)
}
var benchmarkCmd = &cobra.Command{
Use: "benchmark",
Short: "Server benchmarking tests",
Long: `Run internal benchmark funcs by specifying node and batch sizes`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Hugo Static Site Generator v0.9 -- HEAD")
},
}
......@@ -54,18 +54,18 @@ func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "",
rootCmd.Flags().StringVar(&cfgFile, "config", "",
"config file (default is $HOME/.privategrity/server.yaml)")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false,
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false,
"Verbose mode for debugging")
rootCmd.PersistentFlags().IntVarP(&serverIdx, "index", "i", 0,
rootCmd.Flags().IntVarP(&serverIdx, "index", "i", 0,
"Config index to use for local server")
rootCmd.PersistentFlags().Uint64VarP(&batchSize, "batch", "b", 1,
rootCmd.Flags().Uint64VarP(&batchSize, "batch", "b", 1,
"Batch size to use for node server rounds")
rootCmd.PersistentFlags().Uint64VarP(&nodeID, "nodeID", "n",
rootCmd.Flags().Uint64VarP(&nodeID, "nodeID", "n",
math.MaxUint64, "Unique identifier for this node")
viper.BindPFlag("batchSize", rootCmd.PersistentFlags().Lookup("batch"))
viper.BindPFlag("nodeID", rootCmd.PersistentFlags().Lookup("nodeID"))
viper.BindPFlag("batchSize", rootCmd.Flags().Lookup("batch"))
viper.BindPFlag("nodeID", rootCmd.Flags().Lookup("nodeID"))
}
// initConfig reads in config file and ENV variables if set.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment