diff options
author | Patrik Nyblom <[email protected]> | 2012-02-07 18:00:35 +0100 |
---|---|---|
committer | Patrik Nyblom <[email protected]> | 2012-02-07 18:00:35 +0100 |
commit | 6004ec3e1785913ff0b74054cf614a35c180d54a (patch) | |
tree | 1865eab06f4254649f4d9f3e0fbd693c854df5c0 /erts/preloaded/src/erlang.erl | |
parent | 8d59a1fc518719c8c445d9d94b23c173c18b4438 (diff) | |
parent | 6992261d258f2fc0b25ddf99ebcbf66ae02f5df8 (diff) | |
download | otp-6004ec3e1785913ff0b74054cf614a35c180d54a.tar.gz otp-6004ec3e1785913ff0b74054cf614a35c180d54a.tar.bz2 otp-6004ec3e1785913ff0b74054cf614a35c180d54a.zip |
Merge branch 'dgud/sched-work-time/OTP-9858' into maint
* dgud/sched-work-time/OTP-9858:
emulator: Document and test scheduler_wall_time
Implement statistics(scheduler_wall_time)
Diffstat (limited to 'erts/preloaded/src/erlang.erl')
-rw-r--r-- | erts/preloaded/src/erlang.erl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index 4affc9bffe..4cbff3f36e 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -43,6 +43,9 @@ -export([memory/0, memory/1]). -export([alloc_info/1, alloc_sizes/1]). +-export([gather_sched_wall_time_result/1, + await_sched_wall_time_modifications/2]). + -deprecated([hash/2]). % Get rid of autoimports of spawn to avoid clashes with ourselves. @@ -1202,3 +1205,34 @@ receive_allocator(Ref, N, Acc) -> {Ref, _, InfoList} -> receive_allocator(Ref, N-1, insert_info(InfoList, Acc)) end. + +-spec await_sched_wall_time_modifications(Ref, Result) -> boolean() when + Ref :: reference(), + Result :: boolean(). + +await_sched_wall_time_modifications(Ref, Result) -> + sched_wall_time(Ref, erlang:system_info(schedulers)), + Result. + +-spec gather_sched_wall_time_result(Ref) -> [{pos_integer(), + non_neg_integer(), + non_neg_integer()}] when + Ref :: reference(). + +gather_sched_wall_time_result(Ref) when is_reference(Ref) -> + sched_wall_time(Ref, erlang:system_info(schedulers), []). + +sched_wall_time(_Ref, 0) -> + ok; +sched_wall_time(Ref, N) -> + receive Ref -> sched_wall_time(Ref, N-1) end. + +sched_wall_time(_Ref, 0, Acc) -> + Acc; +sched_wall_time(Ref, N, undefined) -> + receive {Ref, _} -> sched_wall_time(Ref, N-1, undefined) end; +sched_wall_time(Ref, N, Acc) -> + receive + {Ref, undefined} -> sched_wall_time(Ref, N-1, undefined); + {Ref, SWT} -> sched_wall_time(Ref, N-1, [SWT|Acc]) + end. |