Use the function clock()
defined in time.h
:
startTime = (float)clock()/CLOCKS_PER_SEC;
/* Do work */
endTime = (float)clock()/CLOCKS_PER_SEC;
timeElapsed = endTime - startTime;
More Related Contents:
- Execution time of C program
- Timing CUDA operations
- Logic behind sizeof operator [duplicate]
- How to Implement stack by function pointer and how to use it [closed]
- Minimize a linear programming system in C
- I got an unknown error on my coding for a C program [closed]
- Pointers program
- Are all data pointers the same size in one platform for all data types? [duplicate]
- Order of local variable allocation on the stack
- What is the meaning of lines starting with a hash sign and number like ‘# 1 “a.c”‘ in the gcc preprocessor output?
- Is unsigned integer subtraction defined behavior?
- Segmentation Fault, large arrays
- Why can’t I convert ‘char**’ to a ‘const char* const*’ in C?
- How do I execute an external program within C code in Linux with arguments?
- stdout thread-safe in C on Linux?
- What does ‘sizeof (function name)’ return?
- Error: Address already in use while binding socket with address but the port number is shown free by `netstat`
- What are the differences between poll and select?
- Left-pad printf with spaces
- Mis-aligned pointers on x86
- Sizeof arrays and pointers
- C syntax for functions returning function pointers
- realloc(): invalid next size when reallocating to make space for strcat on char * [duplicate]
- C code with undefined results, compiler generates invalid code (with -O3)
- Posix regular expression non-greedy
- What do pty and tty mean?
- gcc detect duplicate symbols/functions in static libraries
- Serving multiple domains in one box with SNI
- Why won’t extern link to a static variable?
- How much overhead can the -fPIC flag add?