benchmark code
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,8 @@
|
||||
example/*
|
||||
!example/example.cpp
|
||||
!example/CMakeLists.txt
|
||||
benchmark/*
|
||||
!benchmark/benchmark.cpp
|
||||
!benchmark/CMakeLists.txt
|
||||
.ccls-cache/
|
||||
compile_commands.json
|
||||
|
||||
7
benchmark/CMakeLists.txt
Normal file
7
benchmark/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
|
||||
project(yolo_benchmark)
|
||||
|
||||
add_executable(yolo_benchmark benchmark.cpp)
|
||||
target_include_directories(yolo_benchmark PRIVATE "../include")
|
||||
|
||||
24
benchmark/benchmark.cpp
Normal file
24
benchmark/benchmark.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
||||
#include "yolo/yolo.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
const int iterations = 1000000;
|
||||
int x = 42;
|
||||
int y = 123;
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
for (int i = 0; i < iterations; ++i)
|
||||
{
|
||||
yolo::info("value for x is {} and value for y is {}", x, y);
|
||||
}
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
|
||||
|
||||
std::cout << "Total time taken: " << elapsed << " ns\n";
|
||||
std::cout << "Average time per call: " << static_cast<double>(elapsed) / iterations << " ns\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user