Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
two ways to get cpu cores
#include <thread>
#include <iostream>
#include <unistd.h>
using std::cout;
using std::endl;
int main()
cout << std::thread::hardware_concurrency() << endl;
cout << sysconf(_SC_NPROCESSORS_ONLN) << endl;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment