Skip to content

Instantly share code, notes, and snippets.

@jaseemabid
Created February 19, 2016 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaseemabid/97f7a1770067736b5042 to your computer and use it in GitHub Desktop.
Save jaseemabid/97f7a1770067736b5042 to your computer and use it in GitHub Desktop.
Run the MFA, but log the time taken for it as well.
%% @doc Run the MFA, but log the time taken for it as well.
prof(M, F, A) ->
Note = atom_to_list(M) ++ ":" ++ atom_to_list(F),
prof(Note, M, F, A).
prof(Note, M, F, A) ->
S = os:timestamp(),
Result = apply(M, F, A),
E = os:timestamp(),
Diff = timer:now_diff(E, S)/1.0e6,
lager:notice("[Perf] ~p ~ps", [Note, Diff]),
Result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment