<div dir="ltr">I want to try to understand where does erlang spend time and CPU running my program.<div><br></div><div>What do I try to do for it:</div><div><br></div><div>1) run erlang:statistics(reductions)  before loop</div><div>2) run erlang:trace(all, true, [running])</div><div>3) start collecting messages</div><div>For each </div><div><br></div><div>{trace,Pid,in,_} and {trace,Pid,out,_}<br></div><div><br></div><div>I take process_info(Pid, reductions)  and remember first seen reduction count from process and update last seen reduction count from process</div><div>4) after some time passes I stop this collection and sum all seen deltas between first seen reduction count and last seen reduction count for all processes</div><div><br></div><div>5) when I compare sum of reduction delta  and numbers from statistics(reduction) I see that during 5 seconds sum is 152 242 208  and statistics is 802 940 107</div>















<div><br></div><div><br></div><div>Here is my code:  <a href="https://gist.github.com/maxlapshin/bab46e137d81460672d133bf0cb46a16">https://gist.github.com/maxlapshin/bab46e137d81460672d133bf0cb46a16</a></div><div><br></div><div>Why do I see such difference?</div><div><br></div><div>Where do I loose reduction count in processes?</div><div><br></div><div><br></div></div>