Add Hash, Random, Uuid, Encoding, Bits, Math modules + make Testing deps optional
New header-only modules: - Void::Hash — FNV-1a 32/64, CRC-32, DJB2, MurmurHash3-32, UDL literals - Void::Random — Xoshiro256** PRNG, uniform_int/real, coin_flip, shuffle, random_string - Void::Uuid — v4 (random), v5_lite (name-based), parse, RFC 4122 namespaces - Void::Encoding — Base64 (standard + URL-safe), Hex encode/decode - Void::Bits — popcount, bit extract/deposit, rotation, align, byteswap, masks - Void::Math — Vec2/Vec3/Vec4, Mat4 (identity, translation, scale, rotation) Testing module: move Stacktrace from INTERNAL_DEPS to OPTIONAL_DEPS. Added Detail/Color.hpp shim that delegates to Stacktrace::Color when present or provides inline ANSI fallback otherwise. All Stacktrace calls in SignalHandler, ConsoleReporter, and Runner are gated on VOID_HAS_STACKTRACE. Fix Repr.hpp reflect_struct to handle template specializations that lack std::meta::identifier_of (now guarded by has_identifier check). 33/33 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
42268c6c35
commit
a09e000f0f
65 files changed
+4959
-138
No files matched your search
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace Void::Time
|
||||
{
|
||||
|
||||
/// Minimal RAII wall-clock timer built on std::chrono::steady_clock.
|
||||
///
|
||||
/// Usage:
|
||||
/// Stopwatch sw;
|
||||
/// do_work();
|
||||
/// auto ms = sw.elapsed<std::chrono::milliseconds>();
|
||||
class Stopwatch
|
||||
{
|
||||
public:
|
||||
|
||||
using Clock = std::chrono::steady_clock;
|
||||
using TimePoint = Clock::time_point;
|
||||
using Duration = Clock::duration;
|
||||
|
||||
/// Start the stopwatch at construction time.
|
||||
Stopwatch() noexcept : start_(Clock::now()) {}
|
||||
|
||||
/// Restart from zero.
|
||||
void reset() noexcept { start_ = Clock::now(); }
|
||||
|
||||
/// Elapsed time since construction or last reset().
|
||||
[[nodiscard]] Duration elapsed() const noexcept
|
||||
{
|
||||
return Clock::now() - start_;
|
||||
}
|
||||
|
||||
/// Elapsed time cast to a specific duration type.
|
||||
template <typename D = std::chrono::milliseconds>
|
||||
[[nodiscard]] D elapsed_as() const noexcept
|
||||
{
|
||||
return std::chrono::duration_cast<D>(elapsed());
|
||||
}
|
||||
|
||||
/// Split: return elapsed and reset in one call.
|
||||
[[nodiscard]] Duration split() noexcept
|
||||
{
|
||||
auto d = elapsed();
|
||||
reset();
|
||||
return d;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
TimePoint start_;
|
||||
};
|
||||
|
||||
} // namespace Void::Time
|
||||
Reference in new issue
Block a user