From d419a7831339a7b9cb3ccde1cd27848e951f9776 Mon Sep 17 00:00:00 2001 From: Emiel Por Date: Wed, 11 Dec 2024 19:12:29 -0800 Subject: [PATCH] Compute time per operation in ns. --- benchmarks/free_list_allocator.cpp | 3 +++ benchmarks/pool_allocator.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/benchmarks/free_list_allocator.cpp b/benchmarks/free_list_allocator.cpp index 2ded58ce..22a8bb7c 100644 --- a/benchmarks/free_list_allocator.cpp +++ b/benchmarks/free_list_allocator.cpp @@ -36,6 +36,7 @@ void benchmark_linux_scalability() std::cout << "Linux Scalability:" << std::endl; std::cout << "Time: " << (end - start) / 1e9 << " sec" << std::endl; std::cout << "Throughput: " << 2 * N / ((end - start) / 1e9) << " ops/s" << std::endl; + std::cout << "Time per operation: " << (end - start) / (2 * N) << " ns" << std::endl; delete[] handles; delete[] buffer; @@ -76,6 +77,7 @@ void benchmark_threadtest() std::cout << "Threadtest:" << std::endl; std::cout << "Time: " << (end - start) / 1e9 << " sec" << std::endl; std::cout << "Throughput: " << 2 * N * M / ((end - start) / 1e9) << " ops/s" << std::endl; + std::cout << "Time per operation: " << (end - start) / (2 * N * M) << " ns" << std::endl; delete[] handles; } @@ -129,6 +131,7 @@ void benchmark_larson() std::cout << "Larson benchmark:" << std::endl; std::cout << "Time: " << (end - start) / 1e9 << " sec" << std::endl; std::cout << "Throughput: " << (N * 2 - M) / ((end - start) / 1e9) << " ops/s" << std::endl; + std::cout << "Time per operation: " << (end - start) / (2 * N - M) << " ns" << std::endl; delete[] handles; } diff --git a/benchmarks/pool_allocator.cpp b/benchmarks/pool_allocator.cpp index f327cf4e..6dd2df38 100644 --- a/benchmarks/pool_allocator.cpp +++ b/benchmarks/pool_allocator.cpp @@ -31,6 +31,7 @@ void benchmark_linux_scalability() std::cout << "Linux Scalability:" << std::endl; std::cout << "Time: " << (end - start) / 1e9 << " sec" << std::endl; std::cout << "Throughput: " << 2 * N / ((end - start) / 1e9) << " ops/s" << std::endl; + std::cout << "Time per operation: " << (end - start) / (2 * N) << " ns" << std::endl; delete[] handles; delete[] buffer;