Benchmarking various implementations in Elixir.
- Clone this repo:
git@github.com:unnawut/ex_benchmark.git
- Install dependencies:
mix deps.get
- Run benchmark:
mix benchmark
- Check for emptiness:
Enum.empty?/1
vsEnum.count/1
vs equality comparison (== []
and== %{}
) - Prepend one item to list:
++
vsEnum.concat/2
vs[elem | list]
- Concatenate two lists:
++
vsEnum.concat/2
vsEnum.reduce/3
with[elem | list]
- Delta two lists:
one -- (one -- two)
vsMapSet.intersection/2
- Simple string matching:
Regex.match?
vsString.contains?/2
,String.ends_with?/2
,String.equivalent?/2
,String.starts_with?/2
- Retrieving key-value:
Map.get/3
vsKeyword.get/3
- Dropping key-value:
Map.drop/2
vsKeyword.drop/2
- Inserting key-value:
Map.put/2
vsKeyword.put/2
- Accessing a map:
Map.get/3
,Map.fetch/2
,Access.get/3
vs pattern matching (https://medium.com/learn-elixir/speed-up-data-access-in-elixir-842617030514) - Split a string by position: binary pattern matching vs
String.split_at/2
See results.md.