cli=kingpin.New(filepath.Base(os.Args[0]),"CLI tool for tsdb")
benchCmd=cli.Command("bench","run benchmarks")
benchWriteCmd=benchCmd.Command("write","run a write performance benchmark")
benchWriteOutPath=benchWriteCmd.Flag("out","set the output path").Default("benchout/").String()
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()
)
flag.CommandLine.Set("log.level","debug")
root.Execute()
}
funcNewBenchCommand()*cobra.Command{
c:=&cobra.Command{
Use:"bench",
Short:"run benchmarks",
switchkingpin.MustParse(cli.Parse(os.Args[1:])){
casebenchWriteCmd.FullCommand():
wb:=&writeBenchmark{
outPath:*benchWriteOutPath,
numMetrics:*benchWriteNumMetrics,
samplesFile:*benchSamplesFile,
}
wb.run()
}
c.AddCommand(NewBenchWriteCommand())
returnc
flag.CommandLine.Set("log.level","debug")
}
typewriteBenchmarkstruct{
outPathstring
cleanupbool
numMetricsint
outPathstring
samplesFilestring
cleanupbool
numMetricsint
storage*tsdb.DB
@ -77,22 +70,7 @@ type writeBenchmark struct {
mtxprof*os.File
}
funcNewBenchWriteCommand()*cobra.Command{
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")