summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/hst_suite.go
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2024-06-06 11:24:36 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-06-10 15:28:53 +0000
commit2d1f0e6c73d78cf2a629c9c483ee40854f350d65 (patch)
tree9113ce54593619ac9efc649af31cd57cd0cabbe0 /extras/hs-test/hst_suite.go
parent8a424338addc5c23e7ced85e908fe7d8b087b3d4 (diff)
hs-test: HTTP download benchmarking
HttpTpsTest now use Gomega's gmeasure package and go internal http client. With gmeasure you can create "Experiments" which can produce reports to show the statistical distribution of measurement. Potentially experiments can also be cached and used to identify regression in performance. Type: test Change-Id: Id049fb0344d8ebed71b15e706b053b5c2a18e0de Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras/hs-test/hst_suite.go')
-rw-r--r--extras/hs-test/hst_suite.go19
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)
+}