Skip to content

Instantly share code, notes, and snippets.

@w1k1n9cc
Created June 7, 2016 15:48
Show Gist options
  • Save w1k1n9cc/012be60361e73de86bee0bce51652aa7 to your computer and use it in GitHub Desktop.
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;
}
@qingf639
Copy link

dmxlc3M6Ly9iNjcyODcxOS0wMWM0LTRlYTAtODg4ZC1jMTczMzVjZDU5NTZAMTIwLjI0MS40Ny4xMDc6MjEwMDA/cGF0aD0lMkYlM0ZlZCUzRDIwNDgmc2VjdXJpdHk9dGxzJmVuY3J5cHRpb249bm9uZSZob3N0PWNsb3VkbnMxMjE3LnFpbmdmLmNsb3VkbnMuYml6JmZwPXJhbmRvbWl6ZWQmdHlwZT13cyZzbmk9Y2xvdWRuczEyMTcucWluZ2YuY2xvdWRucy5iaXojY2xvdWRuczEyMTcucWluZ2YuY2xvdWRucy5iaXolMkYxMi4yMy05

@Buggem
Copy link

Buggem commented Feb 20, 2025

the guy above me is an average command and control person

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