Created
July 11, 2011 16:13
-
-
Save amcjen/1076195 to your computer and use it in GitHub Desktop.
Erlang process spawning profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(tester). | |
-export([loopTheFucker/2]). | |
loopTheFucker(N, Total) when N =/= 0 -> | |
spawn(fun() -> true end), | |
loopTheFucker(N-1, Total+N); | |
loopTheFucker(0, Total) -> Total. | |
%% After downloading this, run the following in the Erlang shell (erl on the command line): | |
%% 1> c(tester). | |
%% 2> fprof:trace(start). | |
%% 3> tester:loopTheFucker(100000,0). | |
%% 4> fprof:trace(stop). | |
%% 5> fprof:profile(). | |
%% 6> fprof:analyse({dest, "profile.txt"}). | |
%% | |
%% And then take a look at the profiles.txt file. under "totals", the AAC is the total accumulated time | |
%% for the entire code to run, including all spawned processes completing. The OWN is the length | |
%% of time spent only in our loopTheFucker() function. Zoom! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
14652.397 <- seems high!