Molecular Dynamics  v0.4
Project for the Practical hosted by the Scientific Computing Chair
Benchmark.h
Go to the documentation of this file.
1 //
2 // Created by daniel on 07.05.24.
3 //
4 #pragma once
5 
6 #include <iostream>
7 #include "utils/Logging.h"
8 
16 inline void performBenchmark(Simulator &simulator) {
17  spdlog::set_level(spdlog::level::off);
18  auto tStart = std::chrono::steady_clock::now();
19  simulator.run(true);
20  auto tEnd = std::chrono::steady_clock::now();
21  std::chrono::nanoseconds duration_ns{tEnd - tStart};
22  double duration_s = static_cast<double>(duration_ns.count()) / 1e9;
23  long duration_min = duration_ns.count() / 60000000000;
24  long duration_min_sec = static_cast<long>(std::ceil(duration_s)) - duration_min * 60;
25  std::cout << "Execution time: " << duration_min << " min " << duration_min_sec << " sec | "
26  << duration_s << " sec | " << duration_ns.count() << " ns.\n";
27  std::cout << "Molecule updates per second: " << static_cast<double>(simulator.getTotalMoleculeUpdates()) / duration_s << "\n";
28 
29 }
void performBenchmark(Simulator &simulator)
Measure the execution time of the simulation.
Definition: Benchmark.h:16
This class implements the simulation of the particle system.
Definition: Simulator.h:28
unsigned long long getTotalMoleculeUpdates() const
Definition: Simulator.cpp:236
void run(bool benchmark)
Run the simulation.
Definition: Simulator.cpp:169