Add benchmark

This commit is contained in:
Jeehoon Kang
2020-07-01 14:23:41 +09:00
parent c3237276dc
commit 114f38cbb6
7 changed files with 190 additions and 1 deletions

20
bench/fibonacci.c Normal file
View File

@@ -0,0 +1,20 @@
int fibonacci_loop(int n, int nonce) {
int x = nonce;
int y = nonce;
for (int i = 1; i < n; ++i) {
int newy = x + y;
x = y;
y = newy;
}
return y;
}
int fibonacci_recursive(int n, int nonce) {
if (n < 2) {
return nonce;
}
return fibonacci_recursive(n - 1, nonce) + fibonacci_recursive(n - 2, nonce);
}