Created
December 28, 2019 18:51
-
-
Save ddresselhaus/e1049150c7dae2f42d5d53af1b54dab0 to your computer and use it in GitHub Desktop.
Erlang Scheduler Utilization
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
¯\_(ツ)_/¯ iex -S mix | |
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] | |
Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help) | |
iex(1)> :scheduler.sample() |> :scheduler.utilization() | |
[ | |
{:total, 0.081145584725537, '8.1%'}, | |
{:normal, 1, 0.057692307692307696, '5.8%'}, | |
{:normal, 2, 0.06521739130434782, '6.5%'}, | |
{:normal, 3, 0.34545454545454546, '34.5%'}, | |
{:normal, 4, 0.19148936170212766, '19.1%'}, | |
{:cpu, 5, 0.0, '0.0%'}, | |
{:cpu, 6, 0.0, '0.0%'}, | |
{:cpu, 7, 0.0, '0.0%'}, | |
{:cpu, 8, 0.0, '0.0%'} | |
] | |
iex(2)> doing_work = fn() -> Enum.reduce(1..10_000_000, 1, fn(x, acc) -> x + acc end) end | |
#Function<21.91303403/0 in :erl_eval.expr/5> | |
iex(3)> tasks = Enum.map(1..2, fn(_) -> Task.async(doing_work) end) | |
[ | |
%Task{ | |
owner: #PID<0.417.0>, | |
pid: #PID<0.423.0>, | |
ref: #Reference<0.1046173346.4011851779.128377> | |
}, | |
%Task{ | |
owner: #PID<0.417.0>, | |
pid: #PID<0.424.0>, | |
ref: #Reference<0.1046173346.4011851779.128378> | |
} | |
] | |
iex(4)> :scheduler.sample() |> :scheduler.utilization() | |
[ | |
{:total, 0.381139489194499, '38.1%'}, | |
{:normal, 1, 1.0, '100.0%'}, | |
{:normal, 2, 1.0, '100.0%'}, | |
{:normal, 3, 1.0, '100.0%'}, | |
{:normal, 4, 0.023255813953488372, '2.3%'}, | |
{:cpu, 5, 0.0, '0.0%'}, | |
{:cpu, 6, 0.0, '0.0%'}, | |
{:cpu, 7, 0.0, '0.0%'}, | |
{:cpu, 8, 0.0, '0.0%'} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment