Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug in time diff on unix #27

Closed
wants to merge 2 commits into from
Closed

fix bug in time diff on unix #27

wants to merge 2 commits into from

Conversation

davidhodo
Copy link
Contributor

When comparing times if the second changes, that change should be taken into account calculating the change in nanoseconds. If not you can end up with negative differences when the second field increments.

@wjwwood
Copy link
Owner

wjwwood commented May 23, 2013

Well, I believe you that there might be a problem, but according to this documentation:

http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html

...that code is correct already.

But I think the bug is that the nanosecond diff value can be negative, i.e. the nano seconds of the end might be smaller than the nano seconds of the start even though end comes after start in total time... in which case it should be diff.useconds = (1e9 - abs(end.nanoseconds - start.nanoseconds) / 1000 and diff.seconds -= 1.

Can you try that change instead and I'll also play around with it.

wjwwood added a commit that referenced this pull request May 23, 2013
@wjwwood
Copy link
Owner

wjwwood commented May 23, 2013

Checkout #28 and let me know if that works for you.

@davidhodo davidhodo closed this May 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants