Skip to content

Instantly share code, notes, and snippets.

@felipecustodio
Created December 12, 2016 06:48
Show Gist options
  • Save felipecustodio/9752cfec5ff72aeee57f5b7daf9a8fe7 to your computer and use it in GitHub Desktop.
Save felipecustodio/9752cfec5ff72aeee57f5b7daf9a8fe7 to your computer and use it in GitHub Desktop.
Benchmarking C code for college assignments
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(int argc, char const *argv[]) {
/* benchmarking */
clock_t start_t, end_t;
float delta_t = 0.0;
start_t = clock();
/* what do you want to benchmark? */
end_t = clock();
delta_t = ((float)(end_t - start_t) / 1000000000000.0F ) * CLOCKS_PER_SEC;
printf("Elapsed time: %lf\n", delta_t);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment