summaryrefslogtreecommitdiff
path: root/test/samples/update_counter.exs
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2020-05-16 12:17:40 +0200
committerJordan Bracco <href@random.sh>2020-05-16 12:22:30 +0200
commit447b4c9a2e99a37c0d17e01e79d786f2c11590f5 (patch)
tree87202b1b8e9b09a46ad862a475af0664e5dd753a /test/samples/update_counter.exs
parentRemove ETS backend, add max_retries, add options to limit/3. (diff)
Format and prepare for release
Diffstat (limited to '')
-rw-r--r--test/samples/update_counter.exs33
1 files changed, 19 insertions, 14 deletions
diff --git a/test/samples/update_counter.exs b/test/samples/update_counter.exs
index 6310c57..1d8e837 100644
--- a/test/samples/update_counter.exs
+++ b/test/samples/update_counter.exs
@@ -1,20 +1,25 @@
:ets.new(:limiter_bench, [:public, :named_table])
-:ets.new(:limiter_bench_concurrent, [:public, :named_table, {:read_concurrency, false}, {:write_concurrency, true}])
+
+:ets.new(:limiter_bench_concurrent, [
+ :public,
+ :named_table,
+ {:read_concurrency, false},
+ {:write_concurrency, true}
+])
+
atomics = :atomics.new(1, [])
-update_counter =
- %{
- "ets:update_counter" => fn ->
- :ets.update_counter(:limiter_bench, "bench", {2, 1}, {"bench", 0})
- end,
- "ets:update_counter concurrent" => fn ->
- :ets.update_counter(:limiter_bench, "bench", {2, 1}, {"bench", 0})
- end,
- "atomics:add_get" => fn ->
- :atomics.add_get(atomics, 1, 1)
- end,
- }
+update_counter = %{
+ "ets:update_counter" => fn ->
+ :ets.update_counter(:limiter_bench, "bench", {2, 1}, {"bench", 0})
+ end,
+ "ets:update_counter concurrent" => fn ->
+ :ets.update_counter(:limiter_bench, "bench", {2, 1}, {"bench", 0})
+ end,
+ "atomics:add_get" => fn ->
+ :atomics.add_get(atomics, 1, 1)
+ end
+}
Benchee.run(update_counter, parallel: 1)
Benchee.run(update_counter, parallel: System.schedulers_online())
-