Created
November 30, 2014 15:14
-
-
Save buchgr/09948400c6487f00ef88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdlib> | |
#include "cycle.h" | |
const short NFUNCS = 24; | |
template<int N> | |
int fN(int x) { | |
return fN<N-1>(fN<N-1>(x)); | |
} | |
template<> | |
int fN<0> (int x) { | |
return (x + 23) >> 2; | |
} | |
int main (int argc, char *argv[]) { | |
int iterations = atoi(argv[1]); | |
ticks start = getticks(); | |
int result = 0; | |
int i = iterations; | |
while (i --> 0) { | |
result += fN<NFUNCS>(i); | |
} | |
ticks end = getticks(); | |
double total = elapsed(end, start); | |
double percall = total / ( (1 << (NFUNCS+1)) - 1) / iterations; | |
printf("total cycles: %.2f, cycles per call: %.2f\n", total, percall); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment