-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (40 loc) · 1.05 KB
/
main.cpp
File metadata and controls
52 lines (40 loc) · 1.05 KB
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
47
48
49
50
51
52
#include <iostream>
#include <chrono>
#include "SimpleFibonacciBench.h"
#include "SimpleLoopFibonacciBench.h"
#include <stdlib.h>
#include <sys/resource.h>
enum bench_type{
recursive = 2,
loop = 1
};
int main(int argc, char **argv) {
Bench *bench = NULL;
bench_type type = loop;
char* number = "99999";
if(argc >= 2){
char* benchType = argv[1];
type = static_cast<bench_type>(atol(benchType));
}
if(argc >= 3){
number = argv[2];
}
switch(type){
case recursive:{
//need to change stack size...
rlim_t kStackSize = 16 * std::stoi(number);
struct rlimit rl;
rl.rlim_cur = kStackSize;
setrlimit(RLIMIT_STACK, &rl);
bench = new SimpleFibonacciBench();
}
break;
case loop:{
bench = new SimpleLoopFibonacciBench();
}
break;
}
auto result = bench->run(&number);
std::cout << result.getRunningMilliseconds() << " " << result.result() << "\n";
return 0;
}