Skip to content

Commit

Permalink
improve bench to get more detailed cross core statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
geseq committed Feb 29, 2024
1 parent bdafea5 commit 6f0c36c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bench/simple_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,19 @@ void run_spsc_benchmark_for_all_cpu_pairs(const std::string &name) {
// Sort the cost_per_op in ascending order
std::sort(cost_per_op.begin(), cost_per_op.end(), [](const auto &a, const auto &b) { return std::get<0>(a) < std::get<0>(b); });

// Display the lowest 5 cost_per_op and their corresponding CPU pairs
std::cout << "Lowest 5 Cost per Op (ns/iteration) and their CPU pairs:\n";
// Display the best 5 cost_per_op and their corresponding CPU pairs
std::cout << "\nBest 5 Cost per Op (ns/iteration) and their CPU pairs:\n";
for (size_t i = 0; i < std::min(cost_per_op.size(), size_t(5)); ++i) {
auto [latency, producer_cpu, consumer_cpu] = cost_per_op[i];
std::cout << "Cost: " << latency << ", Producer CPU: " << producer_cpu << ", Consumer CPU: " << consumer_cpu << std::endl;
}

// Display the worst 5 cost_per_op and their corresponding CPU pairs
std::cout << "\nWorst 5 Cost per Op (ns/iteration) and their CPU pairs:\n";
for (size_t i = cost_per_op.size() - 1; i >= std::max(size_t(0), cost_per_op.size() - size_t(5)); --i) {
auto [latency, producer_cpu, consumer_cpu] = cost_per_op[i];
std::cout << "Cost: " << latency << ", Producer CPU: " << producer_cpu << ", Consumer CPU: " << consumer_cpu << std::endl;
}
}

int main() {
Expand Down

0 comments on commit 6f0c36c

Please sign in to comment.