-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS Info #4226
Comments
#codetriage
One simple C approach that works on my simple tests on Linux & Darwin: #include "stdio.h"
#include "unistd.h"
int main(void) {
int ncpu = sysconf(_SC_NPROCESSORS_ONLN);
printf("%d\n", ncpu);
return 0;
} I also read that the Looking at the existing |
The problem with CPU checking is that the method of getting the number of CPUs is pretty fragmented across Mac and Linux. I'm not sure shelling out for this command alone would be the best or most reliable option. I'm currently looking into Rust's source code to see how they do it. So far I've tested a reliable way of pulling the Int values (found from Rust source code) to put into For easier testing, I've been working on this as a separate shard, which can later be integrated into the standard library. https://github.com/TheLonelyGhost/crystal-sysinfo Besides number of CPUs, what information about the platform should we check for? |
Closed by #4449 If other specific OS info is needed, either send a PR or (preferably) open a new issue. Thank you! |
Not sure if this issue is opened before.
It'd be great to have a way of accessing OS specific info from Crystal.
For example accessing how many number of CPU cores e.g.
Here's a Stack Overflow question asking that http://stackoverflow.com/questions/43147366/how-to-detect-number-of-cpu-cores-in-crystal
The text was updated successfully, but these errors were encountered: