This paves the way for implementing daggys and other utilities. Squashed commit of the following: commit 1f77239ab3c9e44d190eef94531a39501c8c4dfe Author: Ian Roddis <gitlab@ie2r.com> Date: Mon Oct 18 16:25:02 2021 -0300 Adding README, stdout support for daggyd logging commit c2c237224e84a3be68aaa597ce98af1365e74a13 Author: Ian Roddis <gitlab@ie2r.com> Date: Mon Oct 18 16:10:29 2021 -0300 removing old daggyd commit cfea2baf61ca10c535801c5a391d2d525a1a2d04 Author: Ian Roddis <gitlab@ie2r.com> Date: Mon Oct 18 16:10:09 2021 -0300 Moving tests into their sub-project folders commit e41ca42069bea1db16dd76b6684a3f692fef6b15 Author: Ian Roddis <gitlab@ie2r.com> Date: Mon Oct 18 15:57:40 2021 -0300 Splitting out daggyd from libdaggy commit be97b146c1d2446f5c03cb78707e921f18c60bd8 Author: Ian Roddis <gitlab@ie2r.com> Date: Mon Oct 18 15:56:55 2021 -0300 Splitting out daggyd from libdaggy commit cb61e140e9d6d8832d61fb7037fd4c0ff6edad00 Author: Ian Roddis <gitlab@ie2r.com> Date: Mon Oct 18 15:49:47 2021 -0300 moving daggy to libdaggy
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#ifdef CATCH_CONFIG_ENABLE_BENCHMARKING
|
|
|
|
#include <catch2/catch.hpp>
|
|
#include <iostream>
|
|
|
|
#include "daggy/DAG.hpp"
|
|
|
|
inline std::string taskName(size_t i)
|
|
{
|
|
return "action_node" + std::to_string(i);
|
|
}
|
|
|
|
daggy::DAG<std::string, size_t> createDAG(size_t N_NODES, size_t MAX_CHILDREN)
|
|
{
|
|
daggy::DAG<std::string, size_t> dag;
|
|
|
|
for (size_t i = 0; i < N_NODES; ++i) {
|
|
dag.addVertex(taskName(i), i);
|
|
}
|
|
|
|
static std::random_device dev;
|
|
static std::mt19937 rng(dev());
|
|
std::uniform_int_distribution<size_t> nDepDist(1, MAX_CHILDREN);
|
|
|
|
for (size_t i = 0; i < N_NODES - 1; ++i) {
|
|
std::string parent = taskName(i);
|
|
std::uniform_int_distribution<size_t> depDist(i + 1, N_NODES - 1);
|
|
size_t nChildren = std::min(nDepDist(rng), N_NODES - i);
|
|
|
|
std::unordered_set<size_t> found;
|
|
size_t tries = 0;
|
|
while (found.size() < nChildren) {
|
|
++tries;
|
|
if (tries > nChildren * 2)
|
|
break;
|
|
auto child = depDist(rng);
|
|
if (found.count(child) > 0)
|
|
continue;
|
|
found.insert(child);
|
|
dag.addEdge(parent, taskName(child));
|
|
}
|
|
}
|
|
|
|
return dag;
|
|
}
|
|
|
|
const size_t N_NODES = 10'000;
|
|
const size_t MAX_CHILDREN = 10;
|
|
|
|
static auto DAG = createDAG(N_NODES, MAX_CHILDREN);
|
|
|
|
TEST_CASE("massive DAGs", "[dag_performance]")
|
|
{
|
|
BENCHMARK_ADVANCED("dag.reset")(Catch::Benchmark::Chronometer meter)
|
|
{
|
|
meter.measure([&] { return DAG.reset(); });
|
|
};
|
|
|
|
BENCHMARK_ADVANCED("dag.isValid")(Catch::Benchmark::Chronometer meter)
|
|
{
|
|
meter.measure([&] { return DAG.isValid(); });
|
|
};
|
|
}
|
|
#endif
|