Skip to content

Commit

Permalink
chore: fix compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveigah committed Oct 25, 2024
1 parent 687eed8 commit 4c7e459
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions lib/mix/tasks/benchmark.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if Mix.env() in [:dev] do
opts = [strategy: :one_for_one, name: Benchmark.Supervisor]
{:ok, _} = Supervisor.start_link([MyClient], opts)

:ok = Klife.TestUtils.wait_producer(MyClient)
:ok = Klife.Testing.setup(MyClient)

Process.sleep(1_000)
apply(Mix.Tasks.Benchmark, :do_run_bench, args)
Expand Down Expand Up @@ -61,35 +61,15 @@ if Mix.env() in [:dev] do
end

def do_run_bench("test", parallel) do
:ets.new(:benchmark_table, [
:set,
:public,
:named_table,
read_concurrency: true
])

:ets.new(:benchmark_table_2, [
:set,
:public,
:named_table
])

Enum.each(1..1000, fn i ->
:ets.insert(:benchmark_table, {{:test, i}, i * 2})
:ets.insert(:benchmark_table_2, {{:test, i}, i * 2})
:persistent_term.put({:test, i}, i * 2)
end)
:persistent_term.put(:known, false)

Benchee.run(
%{
"ets read_concurrency" => fn ->
Enum.each(1..1000, fn i -> :ets.lookup_element(:benchmark_table, {:test, i}, 2) end)
end,
"ets no read_concurrency" => fn ->
Enum.each(1..1000, fn i -> :ets.lookup_element(:benchmark_table_2, {:test, i}, 2) end)
"default" => fn ->
Enum.each(1..1000, fn i -> :persistent_term.get(:unkown, false) end)
end,
"persistent_term" => fn ->
Enum.each(1..1000, fn i -> :persistent_term.get({:test, i}) end)
"no default" => fn ->
Enum.each(1..1000, fn i -> :persistent_term.get(:known, false) end)
end
},
time: 10,
Expand Down

0 comments on commit 4c7e459

Please sign in to comment.