From 47a75650dc24a8977e8de05d291eec34dbe4bc2e Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Wed, 21 Sep 2022 13:38:28 +0200 Subject: [PATCH] fix: Auto clean gluon-bench folder Cleanup generated benchmark data on exit. Use `-skip-cleanup` to keep the generated data. --- benchmarks/gluon_bench/benchmark/run.go | 8 ++++++++ benchmarks/gluon_bench/flags/general.go | 1 + 2 files changed, 9 insertions(+) diff --git a/benchmarks/gluon_bench/benchmark/run.go b/benchmarks/gluon_bench/benchmark/run.go index 49768a62..bcf54e60 100644 --- a/benchmarks/gluon_bench/benchmark/run.go +++ b/benchmarks/gluon_bench/benchmark/run.go @@ -139,5 +139,13 @@ func measureBenchmark(dirConfig BenchDirConfig, iteration uint, bench Benchmark) panic(fmt.Sprintf("Failed to teardown benchmark %v: %v", bench.Name(), err)) } + if !*flags.SkipClean { + fmt.Printf("Cleaning benchmark dir: %v\n", benchPath) + + if err := os.RemoveAll(benchPath); err != nil { + fmt.Fprintf(os.Stderr, "Failed to remote benchmark data dir '%v': %v\n", benchPath, err) + } + } + return reporter.NewBenchmarkStatistics(benchRun.Extra, benchRun.Durations...) } diff --git a/benchmarks/gluon_bench/flags/general.go b/benchmarks/gluon_bench/flags/general.go index 934575f9..44bc0122 100644 --- a/benchmarks/gluon_bench/flags/general.go +++ b/benchmarks/gluon_bench/flags/general.go @@ -10,4 +10,5 @@ var ( Connector = flag.String("connector", "dummy", "Key of the connector implementation registered with ConnectorFactory.") UserName = flag.String("user-name", "user", "Username for the connector user, defaults to 'user'.") UserPassword = flag.String("user-pwd", "password", "Password for the connector user, defaults to 'password'.") + SkipClean = flag.Bool("skip-clean", false, "Do not cleanup benchmark data directory.") )