Skip to content

Instantly share code, notes, and snippets.

@rongyi
Created March 20, 2015 08:49
Show Gist options
  • Save rongyi/3fbbd112e7798039cd8c to your computer and use it in GitHub Desktop.
Save rongyi/3fbbd112e7798039cd8c to your computer and use it in GitHub Desktop.
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