aboutsummaryrefslogtreecommitdiff
path: root/tests/benchmarks/wait-n-no-delay/stm.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/wait-n-no-delay/stm.go')
-rw-r--r--tests/benchmarks/wait-n-no-delay/stm.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/benchmarks/wait-n-no-delay/stm.go b/tests/benchmarks/wait-n-no-delay/stm.go
new file mode 100644
index 0000000..97cac9a
--- /dev/null
+++ b/tests/benchmarks/wait-n-no-delay/stm.go
@@ -0,0 +1,32 @@
+package stm
+
+import (
+ "context"
+ "flag"
+ "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(Limit(n), n)
+ ctx := context.Background()
+ for i := 0; i < n; i++ {
+ go func() {
+ lim.WaitN(ctx, 1)
+ wg.Done()
+ }()
+ }
+ wg.Wait()
+}