-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench_example.cpp
48 lines (39 loc) · 1.03 KB
/
bench_example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*============================================================================
Copyright (C) 2017 akitsu sanae
https://github.com/akitsu-sanae/yurusanae
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
============================================================================*/
#include <iostream>
#include "yurusanae.hpp"
int fib1(int n) {
if (n <= 2)
return n;
else
return fib1(n-1) + fib1(n-2);
}
int fib2(int n) {
auto n1 = 1;
auto n2 = 1;
auto result = 1;
for (int i=0; i<n; i++) {
result = n1 + n2;
n2 = n1;
n1 = result;
}
return result;
}
YURU_BENCH(fib1_bench) {
std::cout << fib1(36) << std::endl;
}
YURU_BENCH(fib2_small_bench) {
std::cout << fib2(36) << std::endl;
}
YURU_BENCH(fib2_big_bench, 1000) {
std::cout << fib2(36) << std::endl;
}
int main() {
fib1_bench{}.exec();
fib2_small_bench{}.exec();
fib2_big_bench{}.exec();
}