Add basic benchmarking retroactively
This commit is contained in:
parent
d56bb85d9a
commit
ac04ea1ac2
4 changed files with 45 additions and 25 deletions
17
d4/main.cxx
17
d4/main.cxx
|
|
@ -48,7 +48,7 @@ int count_xmas(const std::vector<std::string> &grid, int i, int j) {
|
|||
return up + down + left + right + up_left + up_right + down_left + down_right;
|
||||
}
|
||||
|
||||
void part_1() {
|
||||
int part_1() {
|
||||
std::istringstream input_stream(content);
|
||||
std::string line;
|
||||
std::vector<std::string> grid;
|
||||
|
|
@ -66,7 +66,7 @@ void part_1() {
|
|||
}
|
||||
}
|
||||
|
||||
cout << count_acc << endl;
|
||||
return count_acc;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ bool is_mas_cross(const std::vector<std::string>& grid, int i, int j) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void part_2() {
|
||||
int part_2() {
|
||||
std::istringstream input_stream(content);
|
||||
std::string line;
|
||||
std::vector<std::string> grid;
|
||||
|
|
@ -112,11 +112,16 @@ void part_2() {
|
|||
}
|
||||
}
|
||||
|
||||
cout << count_acc << endl;
|
||||
return count_acc;
|
||||
}
|
||||
|
||||
int main() {
|
||||
part_1();
|
||||
part_2();
|
||||
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
|
||||
auto p1_val = part_1();
|
||||
std::chrono::steady_clock::time_point middle = std::chrono::steady_clock::now();
|
||||
auto p2_val = part_2();
|
||||
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
|
||||
cout << "Part 1: " << p1_val << " (" << std::chrono::duration_cast<std::chrono::microseconds>(middle - begin).count() << "µs)" << endl;
|
||||
cout << "Part 2: " << p2_val << " (" << std::chrono::duration_cast<std::chrono::microseconds>(end - middle).count() << "µs)" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue