vendredi 3 août 2018

Portable equivalent to getrusage() in C++?

We're using getrusage() when compiling on Linux to gain some insights into how much CPU-time some operations take in each thread:

getrusage(RUSAGE_THREAD, &before);
.... do work ....
getrusage(RUSAGE_THREAD, &after);

However, because the call is not available on Windows, we have to #ifdef it out on the platform.

I'm sure, Windows has its own means of obtaining the same information, but I'm wondering, if there is a portable way -- either with a standard C++11, or with Boost, which we already use in the project anyway...

Aucun commentaire:

Enregistrer un commentaire