Select Git revision
byID_test.go
benchmark.go 1.60 KiB
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"gitlab.com/privategrity/server/benchmark"
"time"
)
var benchBatchSize uint64
var nodeCount int
var iterations int
var debug bool
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.Flags().BoolVar(&debug, "debug", false,
"Show debug and warning info (default is to only show errors and above)")
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.Printf("Running benchmarks for %d nodes with %d batch size and %d"+
" iterations...\n", nodeCount, benchBatchSize, iterations)
if debug {
jww.SetLogThreshold(jww.LevelDebug)
} else {
jww.SetLogThreshold(jww.LevelError)
}
start := time.Now()
benchmark.PrecompIterations(nodeCount, benchBatchSize, iterations)
precompDelta := (float64(time.Since(start)) / 1000000000) / float64(iterations)
fmt.Printf("Precomp took an average of %f s\n", precompDelta)
start = time.Now()
benchmark.RealtimeIterations(nodeCount, benchBatchSize, iterations)
realtimeDelta := (float64(time.Since(start)) / 1000000000) / float64(iterations)
fmt.Printf("Realtime took an average of %f s\n", realtimeDelta)
},
}