Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #define FLOATING
- int main() {
- int x;
- #ifdef FLOATING
- float z = 1;
- #else
- short z = 1;
- #endif
- struct timespec begin,end;
- clock_gettime(CLOCK_REALTIME,&begin);
- for(x=0; x!=1000000000; x++) {
- #ifdef FLOATING
- z /= 0.00447467;
- #else
- z /= 5000;
- #endif
- }
- clock_gettime(CLOCK_REALTIME,&end);
- printf(
- #ifdef FLOATING
- "Floating point:"
- #else
- "Fixed point:"
- #endif
- "\n"
- );
- printf("TIME: %lu, z=%f\n", end.tv_nsec-begin.tv_nsec, (double)z);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement