Wrong way to go about it IMHO.
You can't depend upon totally accurate information
concerning fork() or creating a thread from outside
the program. A start time init and callback internally
that does your measurement/error handling is how I'd approach it.
Otherwise from man 1 time:
NAME
time - time a simple command or give resource usage
SYNOPSIS
time [options] command [arguments...]
DESCRIPTION
The time command runs the specified program command with
the given arguments. When command finishes, time writes a
message to standard output giving timing statistics about
this program run. These statistics consist of (i) the
elapsed real time between invocation and termination, (ii)
the user CPU time (the sum of the tms_utime and tms_cutime
values in a struct tms as returned by times(2)), and (iii)
the system CPU time (the sum of the tms_stime and
tms_cstime values in a struct tms as returned by
times(2)).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.