본문 바로가기

프로그래밍/c++

time&chronos

#include <iostream>
#include <chrono>
#include <ctime>
using namespace std;
long fibonacci(int n) {
if (n < 3) return 1;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main() {
chrono::time_point<chrono::high_resolution_clock> start, end;
start = chrono::high_resolution_clock::now();
// function to test comes here
fibonacci(i);
end = chrono::high_resolution_clock::now();
chrono::duration<double> elapsed_seconds = end - start;
cout << elapsed_seconds.count() << "s" << endl;
while (1) {}
return 0;
}


'프로그래밍 > c++' 카테고리의 다른 글

relational data structures & strings (C++ STL)  (0) 2018.03.21
dynamic allocation of 2-dimension array  (0) 2018.03.20
c++ reference variables  (0) 2018.03.18
Template classes, operator overloading  (0) 2018.03.18
time&chronos  (0) 2018.03.17
basic data structures  (0) 2018.03.17