Welcome to the Linux Foundation Forum!

Calculate CPU Performance by C Code

How can i calculate percentage cpu and memory usage in linux through C code.

I want to know cpu and memory usage for whole system

Comments

  • I'm not sure if this is the way you're intending, but you could run the "system()" function in your program with the "lscpu" command:



    system("lscpu | grep -E \"(MHz|family|MIPS|L1d|l1i|L2|L3|stepping)\"");

    I hope this helps!

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training