Skip to content

Instantly share code, notes, and snippets.

@w1k1n9cc
Created June 7, 2016 15:48
Show Gist options
  • Select an option

  • Save w1k1n9cc/012be60361e73de86bee0bce51652aa7 to your computer and use it in GitHub Desktop.

Select an option

Save w1k1n9cc/012be60361e73de86bee0bce51652aa7 to your computer and use it in GitHub Desktop.
Get the current time in microseconds in C.
#include <sys/time.h>
/**
* Returns the current time in microseconds.
*/
long getMicrotime(){
struct timeval currentTime;
gettimeofday(&currentTime, NULL);
return currentTime.tv_sec * (int)1e6 + currentTime.tv_usec;
}
@f1redude123

Copy link
Copy Markdown

Thank you very much, this is very helpful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment