From 3d0af6240b61bf5ae61bcab936ea22b4b7c04ac4 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sat, 11 May 2024 21:33:24 +0200 Subject: [PATCH] Add benchmarks comparison job --- scripts/ci/post_benchmark_results.py | 4 +++- src/benchmarks/static_rtree.cpp | 11 ++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/ci/post_benchmark_results.py b/scripts/ci/post_benchmark_results.py index 13769b863..8030944bd 100644 --- a/scripts/ci/post_benchmark_results.py +++ b/scripts/ci/post_benchmark_results.py @@ -11,12 +11,14 @@ PR_NUMBER = os.getenv('PR_NUMBER') REPO_OWNER, REPO_NAME = REPO.split('/') def create_markdown_table(results): + results = sorted(results, key=lambda x: x['name']) header = "| Benchmark | Base | PR |\n|-----------|------|----|" rows = [] for result in results: + name = result['name'] base = result['base'].replace('\n', '
') pr = result['pr'].replace('\n', '
') - row = f"| {result['name']} |
{base}
|
{pr}
|" + row = f"| `{name}` |
{base}
|
{pr}
|" rows.append(row) return f"{header}\n" + "\n".join(rows) diff --git a/src/benchmarks/static_rtree.cpp b/src/benchmarks/static_rtree.cpp index d2dd08fe5..05e924e4d 100644 --- a/src/benchmarks/static_rtree.cpp +++ b/src/benchmarks/static_rtree.cpp @@ -36,8 +36,6 @@ void benchmarkQuery(const std::vector &queries, const std::string &name, QueryT query) { - std::cout << "Running " << name << " with " << queries.size() << " coordinates: " << std::flush; - TIMER_START(query); for (const auto &q : queries) { @@ -46,9 +44,8 @@ void benchmarkQuery(const std::vector &queries, } TIMER_STOP(query); - std::cout << "Took " << TIMER_SEC(query) << " seconds " - << "(" << TIMER_MSEC(query) << "ms" - << ") -> " << TIMER_MSEC(query) / queries.size() << " ms/query " + std::cout << TIMER_MSEC(query) << "ms" + << " -> " << TIMER_MSEC(query) / queries.size() << " ms/query " << "(" << TIMER_MSEC(query) << "ms" << ")" << std::endl; } @@ -66,10 +63,10 @@ void benchmark(BenchStaticRTree &rtree, unsigned num_queries) } benchmarkQuery(queries, - "raw RTree queries (1 result)", + "1 result", [&rtree](const util::Coordinate &q) { return rtree.Nearest(q, 1); }); benchmarkQuery(queries, - "raw RTree queries (10 results)", + "10 results", [&rtree](const util::Coordinate &q) { return rtree.Nearest(q, 10); }); } } // namespace osrm::benchmarks