diff options
Diffstat (limited to 'extras/hs-test/hst_suite.go')
-rw-r--r-- | extras/hs-test/hst_suite.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go index 26dcf4e5a2b..62d1a80e2fc 100644 --- a/extras/hs-test/hst_suite.go +++ b/extras/hs-test/hst_suite.go @@ -5,6 +5,7 @@ import ( "errors" "flag" "fmt" + "github.com/onsi/gomega/gmeasure" "io" "log" "os" @@ -500,3 +501,21 @@ func (s *HstSuite) startWget(finished chan error, server_ip, port, query, netNs } finished <- nil } + +/* +runBenchmark creates Gomega's experiment with the passed-in name and samples the passed-in callback repeatedly (samplesNum times), +passing in suite context, experiment and your data. + +You can also instruct runBenchmark to run with multiple concurrent workers. +You can record multiple named measurements (float64 or duration) within passed-in callback. +runBenchmark then produces report to show statistical distribution of measurements. +*/ +func (s *HstSuite) runBenchmark(name string, samplesNum, parallelNum int, callback func(s *HstSuite, e *gmeasure.Experiment, data interface{}), data interface{}) { + experiment := gmeasure.NewExperiment(name) + + experiment.Sample(func(idx int) { + defer GinkgoRecover() + callback(s, experiment, data) + }, gmeasure.SamplingConfig{N: samplesNum, NumParallel: parallelNum}) + AddReportEntry(experiment.Name, experiment) +} |