Add timer.h for benchmarking

This commit is contained in:
2025-12-01 03:28:00 -05:00
parent 5d5d24168c
commit 66c39108ce
4 changed files with 49 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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;
}