I need to measure, in C++ on Linux (and other Unix-like systems), the CPU (not wall clock) time taken by a long computation, so I’m using clock(). Problem: on 32 bit systems, this wraps around after about 2000 or 4000 seconds.
What’s the recommended workaround for this?
You want to use
getrusagewhich fills the following struct:For completion,
struct timeval:As always, consult the manpage for details (
man getrusage)