Skip to content

Instantly share code, notes, and snippets.

@stwind
Last active December 22, 2015 19:19
Show Gist options
  • Save stwind/6518636 to your computer and use it in GitHub Desktop.
Save stwind/6518636 to your computer and use it in GitHub Desktop.
  • fprof -- maybe helpful
fprof:start().
fprof:trace([start,{procs,processes()},{file,"/opt/fprof.trace"}]).
fprof:trace(stop).
fprof:profile([{file, "/opt/fprof.trace"}]).
fprof:analyse({dest,"fprof_result.analysis"}).
  • cprof -- showoing call count
cprof:start(module).
{_, All} = cprof:analyze().
lists:sort(fun({_,C1},{_,C2}) -> C1>C2 end,[{MFA,C}||{_,_,F}<-All, {MFA,C} <- F]).
  • TCP connection count
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
  • etop
spawn(fun() -> etop:start([{output, text}, {interval, 10}, {lines, 20}, {sort, memory}]) end).
  • memory hogs
lists:usort(fun({_,M1},{_,M2}) -> M1 > M2 end, [{Pid,M}|| {Pid,{memory,M}}<-[{Pid,erlang:process_info(Pid,memory)} || Pid <- processes()]]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment