Skip to content

Instantly share code, notes, and snippets.

@tstellanova
Created May 18, 2015 22:12
Show Gist options
  • Save tstellanova/927084e8ba1bf7c56fcd to your computer and use it in GitHub Desktop.
Save tstellanova/927084e8ba1bf7c56fcd to your computer and use it in GitHub Desktop.
#include <uuid/uuid.h>
#include <time.h>
#include <stdio.h>
#include <ctime>
int main(void)
{
uuid_t blob = {};
clock_t startTime = clock();
const int totalRuns = 1E6;
for (int i = 0; i < totalRuns; i++) {
uuid_generate_time(blob);
}
clock_t endTime = clock();
char outbuf[512];
uuid_unparse(blob, outbuf);
double elapsed_secs = double(endTime - startTime) / CLOCKS_PER_SEC;
double elapsed_usec = elapsed_secs * 1E6;
double per_run = (elapsed_usec / totalRuns);
printf("%0.6f usec per run\n",per_run);
printf("last uuid: %s \n",outbuf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment