Alex D
Alex D

Reputation: 30445

Is there any way to find the number of CPU cores in MRI Ruby (perhaps using a C extension)?

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

Answers (1)

p0deje
p0deje

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

Related Questions