From 5f6607152a96b85f1518028b8f1ee1ef1aefda75 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 23 Jan 2025 09:54:11 -0300 Subject: Move benchmarks from tests/stm.go to tests/benchmarks/* --- tests/benchmarks/allow-n/main.go | 1 + tests/benchmarks/allow-n/stm.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 120000 tests/benchmarks/allow-n/main.go create mode 100644 tests/benchmarks/allow-n/stm.go (limited to 'tests/benchmarks/allow-n') 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() +} -- cgit v1.2.3