You’ve not shown the code where (I assume) you use [font=“Courier New”]gettimeofday()[/font] to fill the [font=“Courier New”]struct timeval[/font]s. If that is what you do the value is in microseconds.
You’ve not shown the code where (I assume) you use [font=“Courier New”]gettimeofday()[/font] to fill the [font=“Courier New”]struct timeval[/font]s. If that is what you do the value is in microseconds.
[font=“Courier New”]struct timeval[/font] has two members: [font=“Courier New”]sec[/font] is the integer part of the time since midnight in seconds. [font=“Courier New”]usec[/font] is the fractional part, expressed in microseconds. So to combine both fields into one value, the difference of the [font=“Courier New”]sec[/font] field is multiplied by one million to turn it into mocroseconds, and then added to the microseconds part to give the final result.
[font=“Courier New”]struct timeval[/font] has two members: [font=“Courier New”]sec[/font] is the integer part of the time since midnight in seconds. [font=“Courier New”]usec[/font] is the fractional part, expressed in microseconds. So to combine both fields into one value, the difference of the [font=“Courier New”]sec[/font] field is multiplied by one million to turn it into mocroseconds, and then added to the microseconds part to give the final result.