Restructure into umbrella modules (~55 -> 16 targets)

Headers move, CMake targets merge, C++ namespaces stay unchanged:
- Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant
- Functional: Pipeline, Either, Result, Retry
- Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval
- Math: +Matrix, Numeric, Random, Histogram
- Text: Str, Format, Tokenizer, Diff, Encoding, Semver
- Data: Json, Csv, Ini
- Async: Coro, Concurrency, EventBus, Observable
- Time: +Bench
- Log: Log facade + Logging framework (facade now header-only, breaking
  the Stacktrace<->Log link cycle the merge would have created)
- System: FileSystem + Process
- Configuration: +Argparse
- Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail

Module system fixes:
- OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no
  longer depends on the alphabetical discovery order of src/ subdirs
  (Testing -> Text would have been silently dropped).
- Every header-only module now has a tracked module.cmake; previously the
  empty src/<Name> marker dirs were untracked, so a fresh clone would have
  silently skipped those modules.
- VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT.

Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files
prefixed: ResultBasic etc.). Test count verified identical (831) before and
after. README/CLAUDE.md module tables updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Fable 5 committed 2026-06-12 18:50:02 +03:00
1 parent da2e93c405
commit 28b94883fd
156 files changed
+278 -220

No files matched your search

+143
View File
@@ -0,0 +1,143 @@
#pragma once
#include <chrono>
#include <cstddef>
#include <functional>
#include <string>
#include <vector>
namespace Void::Bench
{
using Clock = std::chrono::steady_clock;
using Duration = std::chrono::nanoseconds;
// ── BenchResult ───────────────────────────────────────────────────────────────
struct BenchResult {
std::string name;
std::size_t iterations;
Duration total;
Duration min_ns;
Duration max_ns;
[[nodiscard]] double mean_ns() const noexcept
{
return iterations > 0
? static_cast<double>(total.count()) / static_cast<double>(iterations)
: 0.0;
}
[[nodiscard]] double ops_per_sec() const noexcept
{
const double total_s =
std::chrono::duration<double>(total).count();
return total_s > 0.0
? static_cast<double>(iterations) / total_s
: 0.0;
}
};
// ── run ───────────────────────────────────────────────────────────────────────
// Run fn for `iterations` iterations, discarding the first `warmup` runs.
// The body is not inlined / optimized away — use DoNotOptimize below.
[[nodiscard]] inline BenchResult
run(std::string name, std::size_t iterations, std::function<void()> fn,
std::size_t warmup = 3)
{
for (std::size_t i = 0; i < warmup; ++i) fn();
Duration total{0};
Duration mn = Duration::max();
Duration mx = Duration::min();
for (std::size_t i = 0; i < iterations; ++i) {
const auto t0 = Clock::now();
fn();
const auto dt = Clock::now() - t0;
const auto ns = std::chrono::duration_cast<Duration>(dt);
total += ns;
if (ns < mn) mn = ns;
if (ns > mx) mx = ns;
}
return {std::move(name), iterations, total, mn, mx};
}
// ── run_for ───────────────────────────────────────────────────────────────────
// Run fn as many times as possible within `budget`, return result.
template <typename Rep, typename Period>
[[nodiscard]] inline BenchResult
run_for(std::string name, std::chrono::duration<Rep, Period> budget,
std::function<void()> fn, std::size_t warmup = 3)
{
for (std::size_t i = 0; i < warmup; ++i) fn();
Duration total{0};
Duration mn = Duration::max();
Duration mx = Duration::min();
std::size_t count = 0;
const auto deadline = Clock::now() + budget;
while (Clock::now() < deadline) {
const auto t0 = Clock::now();
fn();
const auto ns = std::chrono::duration_cast<Duration>(Clock::now() - t0);
total += ns;
if (ns < mn) mn = ns;
if (ns > mx) mx = ns;
++count;
}
if (mn == Duration::max()) mn = Duration{0};
if (mx == Duration::min()) mx = Duration{0};
return {std::move(name), count, total, mn, mx};
}
// ── DoNotOptimize ─────────────────────────────────────────────────────────────
// Prevent the compiler from optimizing away a value.
template <typename T>
inline void do_not_optimize(T& val) noexcept
{
#if defined(__GNUC__) || defined(__clang__)
asm volatile("" : "+r,m"(val) : : "memory");
#else
volatile T* p = &val;
(void)*p;
#endif
}
template <typename T>
inline void do_not_optimize(const T& val) noexcept
{
#if defined(__GNUC__) || defined(__clang__)
asm volatile("" : : "r,m"(val) : "memory");
#else
volatile const T* p = &val;
(void)*p;
#endif
}
// ── Suite ─────────────────────────────────────────────────────────────────────
// Collect multiple benchmark results.
class Suite
{
public:
void add(BenchResult r) { results_.push_back(std::move(r)); }
[[nodiscard]] const std::vector<BenchResult>& results() const noexcept
{
return results_;
}
[[nodiscard]] std::size_t size() const noexcept { return results_.size(); }
private:
std::vector<BenchResult> results_;
};
} // namespace Void::Bench