Skip to content

Commit

Permalink
refactor: make benchmarks less c++20 dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
DNKpp committed Oct 7, 2023
1 parent e039dd8 commit 1e60a7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CPMAddPackage("gh:catchorg/Catch2@3.4.0")
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")

CPMAddPackage("gh:fmtlib/fmt#10.1.1")
CPMAddPackage("gh:ericniebler/range-v3#0.12.0")
CPMAddPackage("gh:kokkos/mdspan#mdspan-0.6.0")
CPMAddPackage(
name boost
Expand All @@ -20,6 +22,8 @@ target_link_libraries(
Catch2::Catch2WithMain
std::mdspan
Boost::graph
fmt::fmt
range-v3::range-v3
)

catch_discover_tests(Simple-Utility-Benchmarks)
12 changes: 8 additions & 4 deletions benchmarks/graph/AStarBoostComparison.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include <boost/graph/filtered_graph.hpp>
#include <boost/graph/grid_graph.hpp>

#include <range/v3/all.hpp>
#include <fmt/format.h>

#include <fstream>
#include <random>
#include <unordered_map>
Expand Down Expand Up @@ -76,7 +79,7 @@ class maze
friend void random_maze(maze&, std::uint32_t);

explicit maze(const std::size_t x, const std::size_t y)
: m_Grid{boost::array{{x, y}}},
: m_Grid{grid::vertex_descriptor{x, y}},
m_BarrierGrid(make_vertex_subset_complement_filter(m_Grid, m_Barriers))
{
}
Expand Down Expand Up @@ -277,8 +280,9 @@ struct sl::graph::customize::edges_fn<std::reference_wrapper<const maze>>
{
const auto& g = m.get_grid();
const auto [edgesBegin, edgesEnd] = out_edges(node::vertex(current), g);
return std::ranges::subrange{edgesBegin, edgesEnd}
| std::views::transform([&](const auto& e) { return edge_type{target(e, g), 1.}; });

return ranges::subrange{edgesBegin, edgesEnd}
| ranges::views::transform([&](const auto& e) { return edge_type{target(e, g), 1.}; });
}
};

Expand Down Expand Up @@ -431,7 +435,7 @@ TEMPLATE_TEST_CASE_SIG(

SECTION("Compare the results of both implementations.")
{
const std::optional boostSolution = [m, fileName = std::format("./{}_{}x{}.maze.txt", seed, width, height)]() mutable
const std::optional boostSolution = [m, fileName = fmt::format("./{}_{}x{}.maze.txt", seed, width, height)]() mutable
{
auto result = m.solve();
const auto path = artifacts_root_path() / "graph" / "astar_vs_boost";
Expand Down

0 comments on commit 1e60a7e

Please sign in to comment.