Reputation: 500
In java available processors can be obtained by calling
Runtime.getRuntime().availableProcessors()
What is the corresponding api in elixir?
Upvotes: 0
Views: 661
Reputation: 9251
The Elixir way of doing it is System.schedulers/0
or System.schedulers_online/0
, where the former is the total number of schedulers, and the latter is the total number of schedulers which are active (i.e., actually being used)
Upvotes: 2
Reputation: 1412
The :erlang
module provides this information with a system_info
call:
:erlang.system_info(:schedulers_online)
Erlang abstracts CPUs away as "schedulers", and this API allows you to query how many are available.
Upvotes: 1