From c1369399887f751e3a7fa86452ec02dac54b5f77 Mon Sep 17 00:00:00 2001 From: ColumbusTech Date: Fri, 24 Nov 2017 20:54:24 +0300 Subject: [PATCH] Getting CPU Cores Count --- Info.hpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Info.hpp diff --git a/Info.hpp b/Info.hpp new file mode 100644 index 0000000..46bf74c --- /dev/null +++ b/Info.hpp @@ -0,0 +1,37 @@ +#include +#include +#include + +namespace Columbus +{ + + int GetCPUCount(); + + + + int GetCPUCount() + { + #ifdef __linux__ + int counter = 0; + + FILE *cpuinfo = fopen("/proc/cpuinfo", "rb"); + + char* str; + size_t size; + + while(getline(&str, &size, cpuinfo) != -1) + { + if (strstr(str, "processor") != 0) + counter++; + } + + fclose(cpuinfo); + return counter; + #endif + } + +} + + + +