Reputation: 30445
In JRuby, you can just use java.lang.Runtime.get_runtime.available_processors
. Is there anything available for MRI, perhaps using a gem implemented in C?
In a future release of Ruby, it would be nice to see this information available as a automatically defined top-level constant, like RUBY_PLATFORM
and RUBY_VERSION
.
Upvotes: 4
Views: 1736
Reputation: 4053
So far there isn't. But you can either use parallel
gem or take a look how it figures out the number of cores.
Upvotes: 3