Skip to content

Instantly share code, notes, and snippets.

@pfigue
Created April 23, 2015 07:00
Show Gist options
  • Save pfigue/8cbc2ca7fa3c4aa0135e to your computer and use it in GitHub Desktop.
Save pfigue/8cbc2ca7fa3c4aa0135e to your computer and use it in GitHub Desktop.
Example of using libC clock() function.
/*
*
* Compile with: `gcc -o clock clock.c`
*
* [clock(3) - Linux man page](http://linux.die.net/man/3/clock): *The value returned is the CPU time used [by the process] so far[...]*
* [What’s the correct way to use printf to print a clock_t?](http://stackoverflow.com/questions/1083142/what-s-the-correct-way-to-use-printf-to-print-a-clock-t)
*
*/
#include <stdio.h>
#include <time.h>
#include <stdint.h>
int main(int argc, char **argv){
clock_t j;
j = clock();
printf("clock(): %ju\n", (uintmax_t)j );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment