Skip to content

@jonmeredith /schedstat.erl secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
-module(schedstat).
-export([run/0,run/1]).
run() ->
run(1000).
run(Samples) ->
spawn(fun() ->
erlang:trace(all, true, [running,scheduler_id]),
Tid = ets:new(?MODULE, [private]),
[ets:insert(Tid, {S, 0}) || S <- lists:seq(1, erlang:system_info(schedulers))],
loop(Tid, Samples)
end).
loop(Tid, 0) ->
io:format("=== in scheduler count===\n~p\n", [lists:sort(ets:tab2list(Tid))]);
loop(Tid, Times) ->
receive
{trace,_Pid,in,Sched,_MFArity} ->
ets:update_counter(Tid, Sched, {2, 1}),
loop(Tid, Times - 1);
_ ->
loop(Tid, Times - 1)
after
5000 ->
loop(Tid, 0)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.