Skip to content

Instantly share code, notes, and snippets.

View ggcampinho's full-sized avatar

Glauber Campinho ggcampinho

View GitHub Profile
@ggcampinho
ggcampinho / bench.erl
Created September 17, 2017 13:01
Benchmark with implementation
List = fun () ->
L = lists:seq(1, 1000),
lists:map(fun(_) -> ok end, L) ++ lists:map(fun(_) -> {error, "error"} end, L)
end.
Withcase = fun(X) ->
case X of
ok ->
case X of
ok -> ok;
@ggcampinho
ggcampinho / case_bench.exs
Last active September 15, 2017 21:37
translate_with_else
defmodule CaseBench do
use Benchfella
defp ok_or_error_with_atom do
Stream.cycle([:ok, {:error, :err}])
|> Enum.take(1000)
end
defp ok_or_error_with_string do
Stream.cycle([:ok, {:error, "err"}])

This is my kitchen

@ggcampinho
ggcampinho / benchmark_match_domain.out
Last active August 29, 2015 14:26
Benchmark between match an email domain in a regexp versus an array
Calculating -------------------------------------
array 45.561k i/100ms
regexp 48.843k i/100ms
-------------------------------------------------
array 711.188k (± 5.8%) i/s - 3.554M
regexp 797.338k (± 5.9%) i/s - 4.005M
Comparison:
regexp: 797337.6 i/s
array: 711187.6 i/s - 1.12x slower