You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Luke Gorrie wrote on the erlang mailing list (06/11/2007 12:31 PM):
Did I ever post my favourite profiling macro? It's pretty simple:
-define(TIME(Tag,Expr),
(fun() ->
%% NOTE: timer:tc/4 does an annoying 'catch' so we
%% need to wrap the result in 'ok' to be able to
%% detect an unhandled exception.
{__TIME, __RESULT} = timer:tc(erlang,apply,[fun() -> {ok,Expr} end,[]]),
io:format("time(~s): ~18.3fms ~999p~n", [?MODULE,__TIME/1000, Tag]),
case __RESULT of
{ok,_} -> element(2, __RESULT);
{'EXIT',Error} -> exit(Error)
end
end)()).
if you wrap it around a few strategic expressions in your code you end
up with simple running-time summary printouts like this:
time(backup): 3654.744ms restore_table_defs
time(backup): 182.969ms restore_secondary_indexes
time(backup): 311.973ms restore_records
time(backup): 20.928ms checkpoint
time(backup): 5.095ms remove_logs
Update 2:
In what way does this differ from timeouts?
Simply measure wall clock before and after?
Use non-hardware dependent units with automatic calibration á la bogomips? (berps?)
Have different macros for measuring different things?
Macros for checking linear/quadratic/exponential time?
The text was updated successfully, but these errors were encountered:
Luke Gorrie wrote on the erlang mailing list (06/11/2007 12:31 PM):
Update1: Added a macro ?debugTime(Str,Expr) to eunit.hrl in revision 257 (https://forge.process-one.net/changelog/P1Contribs/trunk/eunit?cs=257), inspired by the one by Luke.
Update 2:
In what way does this differ from timeouts?
Simply measure wall clock before and after?
Use non-hardware dependent units with automatic calibration á la bogomips? (berps?)
Have different macros for measuring different things?
Macros for checking linear/quadratic/exponential time?
The text was updated successfully, but these errors were encountered: