(>10kb). Squashed commit of the following: commit b87fa418b4aca78928186a8fa992bef701e044a4 Author: Ian Roddis <tech@kinesin.ca> Date: Mon Feb 14 12:55:34 2022 -0400 removing memory leak commit 5e284ab92dbea991262a08c0cd50d6fc2f912e3b Author: Ian Roddis <tech@kinesin.ca> Date: Mon Feb 14 11:58:57 2022 -0400 Speeding up serialization, fixing payload sizing issue on daggyr commit e5e358820da4c2587741abdc3b6b103e5a4d4dd3 Author: Ian Roddis <tech@kinesin.ca> Date: Sun Feb 13 22:24:04 2022 -0400 changing newlines to std::endl for flush goodness commit 705ec86b75be947e64f4124ec8017cba2c8465e6 Author: Ian Roddis <tech@kinesin.ca> Date: Sun Feb 13 22:16:56 2022 -0400 adding more logging commit aa3db9c23e55da7a0523dc57e268b605ce8faac3 Author: Ian Roddis <tech@kinesin.ca> Date: Sun Feb 13 22:13:56 2022 -0400 Adding threadid commit 3b1a0f1333b2d43bc5ecad0746435504babbaa61 Author: Ian Roddis <tech@kinesin.ca> Date: Sun Feb 13 22:13:24 2022 -0400 Adding some debugging commit 804507e65251858fa597b7c27bcece8d8dfd589d Author: Ian Roddis <tech@kinesin.ca> Date: Sun Feb 13 21:52:53 2022 -0400 Removing curl global cleanup
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][perf]")
|
|
{
|
|
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
|