time - C - Timing my program in seconds with microsecond precision on -


i'm trying find out user time (on linux machine) of c program i've written. i'm calling gettimeofday() once @ beginning of code , once @ end. i'm using timeval struct , difftime(stop.tv_sec,start.tv_sec) number of seconds elapsed. returns whole seconds, "1.000000". however, project requires program timed in seconds microsecond precision, example "1.234567". how can find value? know gettimeofday() records microseconds in .tv_usec, i'm not sure how use value , format correctly.

use timersub function. takes 3 arguments: first initial time, second final one, , third result (the diference). of 3 arguments pointers timeval struct.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -