diff options
author | EuAndreh <eu@euandre.org> | 2025-01-23 09:54:11 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-01-23 11:36:44 -0300 |
commit | 5f6607152a96b85f1518028b8f1ee1ef1aefda75 (patch) | |
tree | be54946ddb2510a317322a2660563c83cab2117c /tests/benchmarks/wait-n-no-delay/stm.go | |
parent | tests/stm.go: Turn example into functional test (diff) | |
download | stm-5f6607152a96b85f1518028b8f1ee1ef1aefda75.tar.gz stm-5f6607152a96b85f1518028b8f1ee1ef1aefda75.tar.xz |
Move benchmarks from tests/stm.go to tests/benchmarks/*
Diffstat (limited to 'tests/benchmarks/wait-n-no-delay/stm.go')
-rw-r--r-- | tests/benchmarks/wait-n-no-delay/stm.go | 32 |
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() +} |