This program is reading data from "/proc/stat" file and then printing it in %s to the console output.
Use CC env variable to set a compiler (flags will be added automaticaly):
export CC=clang
#or
export CC=gccThen compile and execute the program:
make
./bin/cUsageTo test the progarm run:
make testHere is example of loading 4 of 8 cores:
Core Index | %-Load
core # 0 | 7%
core # 1 | 100%
core # 2 | 100%
core # 3 | 0%
core # 4 | 100%
core # 5 | 0%
core # 6 | 100%
core # 7 | 0%
Avg %-Load = 50%
You can load cores of your processor with "stress" in linux:
sudo apt-get install stress
sudo stress --cpu <CORE_NUM> --timeout <SEC_TIMEOUT>