Tidied up example/static test executables

This commit is contained in:
Leonetienne
2022-05-26 18:24:44 +02:00
parent e7c1e17e2c
commit c0418766d9
20 changed files with 574 additions and 69 deletions

View File

@@ -0,0 +1,23 @@
#ifndef GCRYPTEXAMPLE_BENCHMARK_H
#define GCRYPTEXAMPLE_BENCHMARK_H
#include <functional>
#include <chrono>
#include <iostream>
void Benchmark(const std::string& brief, std::function<void()> toBenchmark) {
std::cout << "Benchmarking " << brief << "..." << std::endl;
auto start = std::chrono::steady_clock::now();
toBenchmark();
auto end = std::chrono::steady_clock::now();
double seconds = (double)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 1000.0;
std::cout << seconds << " seconds." << std::endl << std::endl;
return;
}
#endif