Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Measure CPU/memory consumption

I used this for measure the time execution in c++:

struct timeval t1, t2;
gettimeofday(&t1, NULL);
gettimeofday(&t2, NULL);
int milliSeconds = (t2.tv_sec - t1.tv_sec) * 1000 + (t2.tv_usec - t1.tv_usec)/1000;

But I want to measure also the cpu / memory consumption. How can I do this?

Answer*

Cancel
1
  • Thanks for the answer!
    – PRVS
    Commented May 5, 2017 at 9:13