Skip to content

Instantly share code, notes, and snippets.

@raldone01
Created July 18, 2019 15:36
Show Gist options
  • Save raldone01/b8a3e420be776f93aa17728aa318eb00 to your computer and use it in GitHub Desktop.
Save raldone01/b8a3e420be776f93aa17728aa318eb00 to your computer and use it in GitHub Desktop.
timespec timespecDiff(timespec start, timespec stop) {
timespec ret;
ret.tv_sec = stop.tv_sec - start.tv_sec;
if(start.tv_nsec > stop.tv_nsec) {
ret.tv_nsec = 1000000000 - start.tv_nsec + stop.tv_nsec;
ret.tv_sec--;
} else
ret.tv_nsec = stop.tv_nsec - start.tv_nsec;
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment