Skip to content
Snippets Groups Projects
Commit b8778e65 authored by j2-pelczar's avatar j2-pelczar :cowboy:
Browse files

Upload New File

parent 776a002f
No related branches found
No related tags found
No related merge requests found
#ifndef BENCHMARK_HPP
#define BENCHMARK_HPP
#include <chrono>
#include <iostream>
#include <functional>
#include <string>
class Benchmark {
public:
// Function to measure the time of a void function
static void measure(const std::string& name, const std::function<void()>& func) {
using namespace std::chrono;
auto start = high_resolution_clock::now();
func(); // Run the function
auto end = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(end - start);
std::cout << "Benchmark \"" << name << "\": " << duration.count() << " ms\n";
}
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment