Skip to content

Instantly share code, notes, and snippets.

@nox
Forked from blt/lolspeed.erl
Created December 16, 2013 17:13
Show Gist options
  • Save nox/7990570 to your computer and use it in GitHub Desktop.
Save nox/7990570 to your computer and use it in GitHub Desktop.
-module(lolspeed).
-export([main/0]).
-define(LOLEND, 1000000).
%% > lolspeed:main().
%% = {10354,ok}
%% == {10991,ok}
%% =:= {8509,ok}
main() ->
io:format("= ~p~n", [timer:tc(fun bindeq/1, [0])]),
io:format("== ~p~n", [timer:tc(fun eqeq/1, [0])]),
io:format("=:= ~p~n", [timer:tc(fun eqcoloneq/1, [0])]).
bindeq(?LOLEND) ->
ok;
bindeq(N) ->
3.0 = 3.0,
bindeq(N+1).
eqeq(?LOLEND) ->
ok;
eqeq(N) ->
true = (3.0 == 3.0),
eqeq(N+1).
eqcoloneq(?LOLEND) ->
ok;
eqcoloneq(N) ->
true = (3.0 =:= 3.0),
eqcoloneq(N+1).
{module, lolspeed}. %% version = 0
{exports, [{main,0},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 22}.
{function, main, 0, 2}.
{label,1}.
{line,[{location,"lolspeed.erl",12}]}.
{func_info,{atom,lolspeed},{atom,main},0}.
{label,2}.
{allocate,0,0}.
{make_fun2,{f,21},0,0,0}.
{move,{literal,[0]},{x,1}}.
{line,[{location,"lolspeed.erl",13}]}.
{call_ext,2,{extfunc,timer,tc,2}}.
{test_heap,2,1}.
{put_list,{x,0},nil,{x,1}}.
{move,{literal,"= ~p~n"},{x,0}}.
{line,[{location,"lolspeed.erl",13}]}.
{call_ext,2,{extfunc,io,format,2}}.
{make_fun2,{f,19},0,0,0}.
{move,{literal,[0]},{x,1}}.
{line,[{location,"lolspeed.erl",14}]}.
{call_ext,2,{extfunc,timer,tc,2}}.
{test_heap,2,1}.
{put_list,{x,0},nil,{x,1}}.
{move,{literal,"== ~p~n"},{x,0}}.
{line,[{location,"lolspeed.erl",14}]}.
{call_ext,2,{extfunc,io,format,2}}.
{make_fun2,{f,17},0,0,0}.
{move,{literal,[0]},{x,1}}.
{line,[{location,"lolspeed.erl",15}]}.
{call_ext,2,{extfunc,timer,tc,2}}.
{test_heap,2,1}.
{put_list,{x,0},nil,{x,1}}.
{move,{literal,"=:= ~p~n"},{x,0}}.
{line,[{location,"lolspeed.erl",15}]}.
{call_ext_last,2,{extfunc,io,format,2},0}.
{function, bindeq, 1, 4}.
{label,3}.
{line,[{location,"lolspeed.erl",17}]}.
{func_info,{atom,lolspeed},{atom,bindeq},1}.
{label,4}.
{test,is_eq_exact,{f,5},[{x,0},{integer,1000000}]}.
{move,{atom,ok},{x,0}}.
return.
{label,5}.
{line,[{location,"lolspeed.erl",21}]}.
{gc_bif,'+',{f,0},1,[{x,0},{integer,1}],{x,0}}.
{call_only,1,{f,4}}.
{function, eqeq, 1, 7}.
{label,6}.
{line,[{location,"lolspeed.erl",23}]}.
{func_info,{atom,lolspeed},{atom,eqeq},1}.
{label,7}.
{test,is_eq_exact,{f,8},[{x,0},{integer,1000000}]}.
{move,{atom,ok},{x,0}}.
return.
{label,8}.
{line,[{location,"lolspeed.erl",27}]}.
{gc_bif,'+',{f,0},1,[{x,0},{integer,1}],{x,0}}.
{call_only,1,{f,7}}.
{function, eqcoloneq, 1, 10}.
{label,9}.
{line,[{location,"lolspeed.erl",29}]}.
{func_info,{atom,lolspeed},{atom,eqcoloneq},1}.
{label,10}.
{test,is_eq_exact,{f,11},[{x,0},{integer,1000000}]}.
{move,{atom,ok},{x,0}}.
return.
{label,11}.
{line,[{location,"lolspeed.erl",33}]}.
{gc_bif,'+',{f,0},1,[{x,0},{integer,1}],{x,0}}.
{call_only,1,{f,10}}.
{function, module_info, 0, 13}.
{label,12}.
{line,[]}.
{func_info,{atom,lolspeed},{atom,module_info},0}.
{label,13}.
{move,{atom,lolspeed},{x,0}}.
{line,[]}.
{call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
{function, module_info, 1, 15}.
{label,14}.
{line,[]}.
{func_info,{atom,lolspeed},{atom,module_info},1}.
{label,15}.
{move,{x,0},{x,1}}.
{move,{atom,lolspeed},{x,0}}.
{line,[]}.
{call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
{function, '-main/0-fun-2-', 1, 17}.
{label,16}.
{line,[{location,"lolspeed.erl",15}]}.
{func_info,{atom,lolspeed},{atom,'-main/0-fun-2-'},1}.
{label,17}.
{call_only,1,{f,10}}.
{function, '-main/0-fun-1-', 1, 19}.
{label,18}.
{line,[{location,"lolspeed.erl",14}]}.
{func_info,{atom,lolspeed},{atom,'-main/0-fun-1-'},1}.
{label,19}.
{call_only,1,{f,7}}.
{function, '-main/0-fun-0-', 1, 21}.
{label,20}.
{line,[{location,"lolspeed.erl",13}]}.
{func_info,{atom,lolspeed},{atom,'-main/0-fun-0-'},1}.
{label,21}.
{call_only,1,{f,4}}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment