cli=kingpin.New(filepath.Base(os.Args[0]),"CLI tool for tsdb")
benchCmd=cli.Command("bench","run benchmarks")
root:=&cobra.Command{
benchWriteCmd=benchCmd.Command("write","run a write performance benchmark")
Use:"tsdb",
benchWriteOutPath=benchWriteCmd.Flag("out","set the output path").Default("benchout/").String()
Short:"CLI tool for tsdb",
benchWriteNumMetrics=benchWriteCmd.Flag("metrics","number of metrics to read").Default("10000").Int()
}
benchSamplesFile=benchWriteCmd.Arg("file","input file with samples data, default is (../../testdata/20k.series)").Default("../../testdata/20k.series").String()
root.AddCommand(
NewBenchCommand(),
)
)
flag.CommandLine.Set("log.level","debug")
switchkingpin.MustParse(cli.Parse(os.Args[1:])){
casebenchWriteCmd.FullCommand():
root.Execute()
wb:=&writeBenchmark{
}
outPath:*benchWriteOutPath,
numMetrics:*benchWriteNumMetrics,
funcNewBenchCommand()*cobra.Command{
samplesFile:*benchSamplesFile,
c:=&cobra.Command{
}
Use:"bench",
wb.run()
Short:"run benchmarks",
}
}
c.AddCommand(NewBenchWriteCommand())
flag.CommandLine.Set("log.level","debug")
returnc
}
}
typewriteBenchmarkstruct{
typewriteBenchmarkstruct{
outPathstring
outPathstring
cleanupbool
samplesFilestring
numMetricsint
cleanupbool
numMetricsint
storage*tsdb.DB
storage*tsdb.DB
@ -77,22 +70,7 @@ type writeBenchmark struct {
mtxprof*os.File
mtxprof*os.File
}
}
funcNewBenchWriteCommand()*cobra.Command{
func(b*writeBenchmark)run(){
varwbwriteBenchmark
c:=&cobra.Command{
Use:"write <file>",
Short:"run a write performance benchmark",
Run:wb.run,
}
c.PersistentFlags().StringVar(&wb.outPath,"out","benchout/","set the output path")
c.PersistentFlags().IntVar(&wb.numMetrics,"metrics",10000,"number of metrics to read")