Add timer.h for benchmarking
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include "timer.h"
|
||||
|
||||
bool get_dir(const std::string& line) {
|
||||
if (line.find('R') != std::string::npos) {
|
||||
@@ -96,6 +97,8 @@ int rotate (const int state, const bool direction, const int number) {
|
||||
}
|
||||
|
||||
int main() {
|
||||
Timer timer;
|
||||
|
||||
std::ifstream stream("input/day1/p1.txt");
|
||||
std::string line;
|
||||
int state = 50;
|
||||
@@ -108,7 +111,11 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
|
||||
std::cout << "Password: " << password << std::endl;
|
||||
|
||||
timer.print();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include <chrono>
|
||||
#include "timer.h"
|
||||
|
||||
bool get_dir(const std::string& line) {
|
||||
if (line.find('R') != std::string::npos) {
|
||||
@@ -140,6 +140,8 @@ int get_number(const std::string& line) {
|
||||
}
|
||||
|
||||
int main() {
|
||||
Timer timer;
|
||||
|
||||
std::ifstream stream("input/day1/p1.txt");
|
||||
std::string line;
|
||||
int state = 50;
|
||||
@@ -151,7 +153,11 @@ int main() {
|
||||
password = std::get<1>(temp);
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
|
||||
std::cout << "Password: " << password << std::endl;
|
||||
|
||||
timer.print();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user