aboutsummaryrefslogtreecommitdiff
path: root/tests/benchmarks/allow-n
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/allow-n')
l---------tests/benchmarks/allow-n/main.go1
-rw-r--r--tests/benchmarks/allow-n/stm.go31
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/benchmarks/allow-n/main.go b/tests/benchmarks/allow-n/main.go
new file mode 120000
index 0000000..f67563d
--- /dev/null
+++ b/tests/benchmarks/allow-n/main.go
@@ -0,0 +1 @@
+../../main.go \ No newline at end of file
diff --git a/tests/benchmarks/allow-n/stm.go b/tests/benchmarks/allow-n/stm.go
new file mode 100644
index 0000000..2b0b342
--- /dev/null
+++ b/tests/benchmarks/allow-n/stm.go
@@ -0,0 +1,31 @@
+package stm
+
+import (
+ "flag"
+ "time"
+ "sync"
+)
+
+
+
+var nFlag = flag.Int(
+ "n",
+ 1_000,
+ "The number of iterations to execute",
+)
+
+func MainTest() {
+ flag.Parse()
+ n := *nFlag
+
+ var wg sync.WaitGroup
+ wg.Add(n)
+ lim := NewLimiter(Every(1*time.Second), 1)
+ for i := 0; i < n; i++ {
+ go func() {
+ lim.AllowN(1)
+ wg.Done()
+ }()
+ }
+ wg.Wait()
+}