Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework mongoose_mam_id as a persistent_term with an atomic
```elixir def next_id() do Benchee.run( %{ "native code" => fn list -> Enum.map(list, fn t -> :mongoose_mam_id.next_unique(t) end) end, "pure erlang" => fn list -> Enum.map(list, fn t -> :mongoose_mam_id_2.next_unique(t) end) end, }, inputs: %{ "1M monotonic" => monotonic_list(100_000_000) }, formatters: [ {Benchee.Formatters.Console, extended_statistics: true} ], parallel: 1, time: 5, warmup: 0 ) end defp monotonic_list(size) do fun = fn(_, [head | _] = acc) -> next = head + :rand.uniform(20) - 1 [next | acc] end :lists.reverse(:lists.foldl(fun, [:rand.uniform(20)], :lists.seq(1, size))) end ``` returns ``` Operating System: macOS CPU Information: Apple M3 Pro Number of Available Cores: 12 Available memory: 36 GB Elixir 1.17.3 Erlang 27.1.2 JIT enabled: true Benchmark suite executing with the following configuration: warmup: 0 ns time: 5 s memory time: 0 ns reduction time: 0 ns parallel: 1 inputs: 1M monotonic Estimated total run time: 10 s Benchmarking native code with input 1M monotonic ... Benchmarking pure erlang with input 1M monotonic ... Calculating statistics... Formatting results... Name ips average deviation median 99th % pure erlang 0.31 3.23 s ±10.49% 3.23 s 3.47 s native code 0.28 3.54 s ±6.26% 3.54 s 3.70 s Comparison: pure erlang 0.31 native code 0.28 - 1.10x slower +0.32 s Extended statistics: Name minimum maximum sample size mode pure erlang 2.99 s 3.47 s 2 None native code 3.39 s 3.70 s 2 None ```
- Loading branch information