AB
https://virviil.github.io/2018/04/06/elixir-do-you-have-http-requests-you-are-doing-them-wrong/
Просто может кто-то за меня сделает репу с бенчмарками
Size: a a a
AB
AB
ŹR
ŹR
ŹR
ŹR
ŹR
ŹR
DR
defmodule Test do
def to_try(arg) do
arg
else
:ok -> :hit
_ -> :no_hit
end
def to_case(arg) do
case arg do
:ok -> :hit
_ -> :no_hit
end
end
end
-module('Elixir.Test').
-compile([no_auto_import]).
-export(['__info__'/1, to_case/1, to_try/1]).
-spec '__info__'(attributes | compile | functions |
macros | md5 | module | deprecated) -> any().
'__info__'(module) -> 'Elixir.Test';
'__info__'(functions) -> [{to_case, 1}, {to_try, 1}];
'__info__'(macros) -> [];
'__info__'(Key = attributes) ->
erlang:get_module_info('Elixir.Test', Key);
'__info__'(Key = compile) ->
erlang:get_module_info('Elixir.Test', Key);
'__info__'(Key = md5) ->
erlang:get_module_info('Elixir.Test', Key);
'__info__'(deprecated) -> [].
to_case(_arg@1) ->
case _arg@1 of
ok -> hit;
_ -> no_hit
end.
to_try(_arg@1) ->
try _arg@1 of
ok -> hit;
_ -> no_hit
end.
def to_try(arg) do
arg
rescue
exception in bla -> :hit
_ -> :no_hit
end
DR
ŹR
ŹR
DR
DR
else
- скрывается try - не очень хорошо.DR
def to_try(value) do
foo!
catch
:exit, reason -> {:error, reason}
end
DR
ŹR
ŹR
DR
DR
try do
...
catch
... ->
...
rescue
... ->
...
else
... ->
...
after
... ->
end