tier0.dhover×899all
/**
 * Tier-0 cheap resource counters, in pure D — the always-available I/O-bound
 * signal that needs no `perf_event`, no tracepoints, and no elevated privilege.
 *
 * Two process-wide cumulative sources are sampled as deltas across a counting
 * pass (mirroring `perf.d`'s separate pass, so the reported ns/iter timings are
 * never perturbed):
 *
 * $(LIST
 *   * `getrusage(RUSAGE_SELF)` — minor/major page faults and voluntary /
 *     involuntary context switches (the direct blocked-on-I/O vs preempted
 *     signal);
 *   * `/proc/self/io` — `syscr`/`syscw` (read/write syscall counts), `rchar`/
 *     `wchar` (bytes through the syscall layer, cache included) and `read_bytes`/
 *     `write_bytes` (bytes that actually hit the block device). The gap between
 *     `rchar` and `read_bytes` is the page-cache-hit signal, for free.
 * )
 *
 * All metrics are `quantitative`: each `timed()` call is bracketed by its own
 * pair of cheap snapshots, so — like `perf.d`'s ioctl `ENABLE`/`DISABLE` — the
 * untimed `between()` teardown (a `benchCase`'s result release) is excluded from
 * the counted window. The snapshots cannot pause, so each bracket's own `/proc`
 * read lands inside its window; `tryOpen` calibrates that per-bracket self-cost
 * (median of several empty brackets) and `count` reports the workload net of it,
 * clamped at zero — so a body that does no I/O reads ≈0, not the instrumentation
 * constant. The getrusage-sourced page-fault and context-switch columns carry no
 * per-bracket cost. On macOS a darwin body serves the same surface from
 * `getrusage`'s maintained BSD-tail fields plus `proc_pid_rusage`'s disk-I/O
 * byte counters; elsewhere the group is permanently unavailable.
 */
module 
(package) sparkles
sparkles
.
(package) sparkles.test_runner
test_runner
.
(module) sparkles.test_runner.tier0

Tier-0 cheap resource counters, in pure D — the always-available I/O-bound signal that needs no perf_event, no tracepoints, and no elevated privilege.

Two process-wide cumulative sources are sampled as deltas across a counting pass (mirroring perf.d's separate pass, so the reported ns/iter timings are never perturbed):

  • getrusage(RUSAGE_SELF) — minor/major page faults and voluntary / involuntary context switches (the direct blocked-on-I/O vs preempted signal);

  • /proc/self/iosyscr/syscw (read/write syscall counts), rchar/ wchar (bytes through the syscall layer, cache included) and read_bytes/ write_bytes (bytes that actually hit the block device). The gap between rchar and read_bytes is the page-cache-hit signal, for free.

All metrics are quantitative: each timed() call is bracketed by its own pair of cheap snapshots, so — like perf.d's ioctl ENABLE/DISABLE — the untimed between() teardown (a benchCase's result release) is excluded from the counted window. The snapshots cannot pause, so each bracket's own /proc read lands inside its window; tryOpen calibrates that per-bracket self-cost (median of several empty brackets) and count reports the workload net of it, clamped at zero — so a body that does no I/O reads ≈0, not the instrumentation constant. The getrusage-sourced page-fault and context-switch columns carry no per-bracket cost. On macOS a darwin body serves the same surface from getrusage's maintained BSD-tail fields plus proc_pid_rusage's disk-I/O byte counters; elsewhere the group is permanently unavailable.

tier0
;
import
(package) sparkles
sparkles
.
(package) sparkles.test_runner
test_runner
.
(module) sparkles.test_runner.capability

The capability seam: what can this host measure, as a first-class value.

Every acquisition backend advertises a CapabilityReport after its open handshake — one Capability flag per survey concern, with a reasoned CapabilityAbsence entry for everything it cannot deliver on this host, this run. Capability is a runtime probe result, never a compile-time assumption: the same binary reports differently under a hardened perf_event_paranoid, a root-only tracefs, or a PMU-less container.

isCounterBackend names the instance contract CounterGroups has always demanded of a tier (available/status/capabilities/close/count); optional primitives (hasSnapshot, hasNamedColumns) unlock optional behavior by presence, per the DbI guidelines. Construction is deliberately outside the trait — tryOpen arity varies per tier (perf: bool; syscalls: bool + names) and stays a per-tier concern of CounterGroups.open.

The evidence base is the CPU-PMU research catalog (docs/research/cpu-pmu/backend-proposal.md §2); the shipped shapes deviate from its sketch where the real surface demanded it (see docs/specs/test-runner/SPEC.md §6.2).

capability
:
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
,
(struct) sparkles.test_runner.capability.CapabilityAbsence

One absent capability with its host-grounded reason.

CapabilityAbsence
,
(struct) sparkles.test_runner.capability.CapabilityReport

What a backend can deliver on this host, this run: the present flags OR-ed together, and a reasoned entry per absent flag (in allCapabilities order). A flag mentioned in neither is outside the backend's domain.

CapabilityReport
,
(alias) sparkles.test_runner.tier0.has = bool sparkles.test_runner.capability.has(in sparkles.test_runner.capability.CapabilityReport r, sparkles.test_runner.capability.Capability flag) pure nothrow @nogc @safe

Whether flag is advertised present.

has
,
(alias template) sparkles.test_runner.tier0.hasNamedColumns = sparkles.test_runner.capability.hasNamedColumns(B)

Optional

dynamic per-column names parallel to a row's counts (the syscall tier's named tracepoints).

hasNamedColumns
,
(alias template) sparkles.test_runner.tier0.hasSnapshot = sparkles.test_runner.capability.hasSnapshot(B)

Optional

a cheap cumulative snapshot (the snapshot/delta source shape — tier-0 today, the workload window model tomorrow). Presence, not declaration, unlocks it.

hasSnapshot
,
(alias template) sparkles.test_runner.tier0.isCounterBackend = sparkles.test_runner.capability.isCounterBackend(B)

The required backend surface — CounterGroups' implicit per-tier contract made nameable: const-callable probe observers (available, status, capabilities), resource release, and the bracketed counting pass returning that backend's row-stats value. The return type of count is deliberately unconstrained (it differs per tier), as are attributes (count is a template with inferred attributes).

isCounterBackend
,
(alias) sparkles.test_runner.tier0.reasonFor = string sparkles.test_runner.capability.reasonFor(in sparkles.test_runner.capability.CapabilityReport r, sparkles.test_runner.capability.Capability flag) pure nothrow @nogc @safe

The reason flag is absent; null when present or outside the report's domain. (Returning the second-level slice out of an in report is legal under dip1000 — scope is non-transitive; a helper returning the first-level absences slice itself would not compile.)

reasonFor
;
/// Per-iteration Tier-0 counter deltas of one counting pass. A field is `nan` /// when its source could not be read on this machine. struct
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
{ ulong
(field) ulong sparkles.test_runner.tier0.Tier0Stats.iters

counting-pass iterations

iters
; /// counting-pass iterations
double
(field) double sparkles.test_runner.tier0.Tier0Stats.minflt

minor page faults per iteration (getrusage)

minflt
= 0; /// minor page faults per iteration (getrusage)
double
(field) double sparkles.test_runner.tier0.Tier0Stats.majflt

major page faults per iteration (getrusage)

majflt
= 0; /// major page faults per iteration (getrusage)
double
(field) double sparkles.test_runner.tier0.Tier0Stats.volCs

voluntary context switches per iteration (blocked on I/O)

volCs
= 0; /// voluntary context switches per iteration (blocked on I/O)
double
(field) double sparkles.test_runner.tier0.Tier0Stats.involCs

involuntary context switches per iteration (preempted)

involCs
= 0; /// involuntary context switches per iteration (preempted)
double
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
= 0; /// read syscalls per iteration (/proc/self/io)
double
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
= 0; /// write syscalls per iteration
double
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
= 0; /// bytes read through the syscall layer (cache included)
double
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
= 0; /// bytes written through the syscall layer
double
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
= 0; /// bytes that actually hit the block device (reads)
double
(field) double sparkles.test_runner.tier0.Tier0Stats.wrBytes

bytes that actually hit the block device (writes)

wrBytes
= 0; /// bytes that actually hit the block device (writes)
} /// Page-cache hit rate in percent: the fraction of bytes served without touching /// the block device (`1 − read_bytes ÷ rchar`). `nan` when nothing was read (or /// `read_bytes` is unavailable). A cold read's kernel readahead can pull more from /// disk than userspace consumed (`read_bytes > rchar`), so the ratio is clamped to /// a 0% hit rate rather than reported as `nan` — the cold case the metric reveals. double
double sparkles.test_runner.tier0.cacheHitPercent(in sparkles.test_runner.tier0.Tier0Stats t) pure nothrow @nogc @safe

Page-cache hit rate in percent: the fraction of bytes served without touching the block device (1 − read_bytes ÷ rchar). nan when nothing was read (or read_bytes is unavailable). A cold read's kernel readahead can pull more from disk than userspace consumed (read_bytes > rchar), so the ratio is clamped to a 0% hit rate rather than reported as nan — the cold case the metric reveals.

cacheHitPercent
(in
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(parameter) const(sparkles.test_runner.tier0.Tier0Stats) t
t
) @safe pure nothrow @nogc
{ import
(package) std
std
.
(package) std.algorithm
algorithm
.
(module) std.algorithm.comparison

This is a submodule of std.algorithm. It contains generic comparison algorithms.

Function Name Description
among Checks if a value is among a set of values, e.g. if (v.among(1, 2, 3)) // v is 1, 2 or 3
castSwitch (new A()).castSwitch((A a)=>1,(B b)=>2) returns 1.
clamp clamp(1, 3, 6) returns 3. clamp(4, 3, 6) returns 4.
cmp cmp("abc", "abcd") is -1, cmp("abc", "aba") is 1, and cmp("abc", "abc") is 0.
either Return first parameter p that passes an if (p) test, e.g. either(0, 42, 43) returns 42.
equal Compares ranges for element-by-element equality, e.g. equal([1, 2, 3], [1.0, 2.0, 3.0]) returns true.
isPermutation isPermutation([1, 2], [2, 1]) returns true.
isSameLength isSameLength([1, 2, 3], [4, 5, 6]) returns true.
levenshteinDistance levenshteinDistance("kitten", "sitting") returns 3 by using the Levenshtein distance algorithm.
levenshteinDistanceAndPath levenshteinDistanceAndPath("kitten", "sitting") returns tuple(3, "snnnsni") by using the Levenshtein distance algorithm.
max max(3, 4, 2) returns 4.
min min(3, 4, 2) returns 2.
mismatch mismatch("oh hi", "ohayo") returns tuple(" hi", "ayo").
predSwitch 2.predSwitch(1, "one", 2, "two", 3, "three") returns "two".

Source

std/algorithm/comparison.d

@copyrightAndrei Alexandrescu 2008-.@licenseBoost License 1.0.@authorsAndrei Alexandrescu
comparison
:
(alias template) min = std.algorithm.comparison.min(T...)(T args) if (T.length >= 2 && !is(CommonType!T == void))

Iterates the passed arguments and returns the minimum value.

Params: args = The values to select the minimum from. At least two arguments must be passed, and they must be comparable with <.

Returns: The minimum of the passed-in values. The type of the returned value is the type among the passed arguments that is able to store the smallest value. If at least one of the arguments is NaN, the result is an unspecified value. See $(REF minElement, std,algorithm,searching) for examples on how to cope with NaNs.

See_Also: $(REF minElement, std,algorithm,searching)

min
;
return
(parameter) const(sparkles.test_runner.tier0.Tier0Stats) t
t
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
> 0 &&
(parameter) const(sparkles.test_runner.tier0.Tier0Stats) t
t
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
>= 0
? (1 -
const(double) std.algorithm.comparison.min!(const(double), const(double))(const(double) a, const(double) b) pure nothrow @nogc @safe

Iterates the passed arguments and returns the minimum value.

Examples

int a = 5;
short b = 6;
double c = 2;
auto d = min(a, b);
static assert(is(typeof(d) == int));
assert(d == 5);
auto e = min(a, b, c);
static assert(is(typeof(e) == double));
assert(e == 2);
ulong f = 0xffff_ffff_ffff;
const uint g = min(f, 0xffff_0000);
assert(g == 0xffff_0000);
dchar h = 100;
uint i = 101;
static assert(is(typeof(min(h, i)) == dchar));
static assert(is(typeof(min(i, h)) == uint));
assert(min(h, i) == 100);

With arguments of mixed signedness, the return type is the one that can store the lowest values.

int a = -10;
uint f = 10;
static assert(is(typeof(min(a, f)) == int));
assert(min(a, f) == -10);

User-defined types that support comparison with < are supported.

import std.datetime;
assert(min(Date(2012, 12, 21), Date(1982, 1, 4)) == Date(1982, 1, 4));
assert(min(Date(1982, 1, 4), Date(2012, 12, 21)) == Date(1982, 1, 4));
assert(min(Date(1982, 1, 4), Date.min) == Date.min);
assert(min(Date.min, Date(1982, 1, 4)) == Date.min);
assert(min(Date(1982, 1, 4), Date.max) == Date(1982, 1, 4));
assert(min(Date.max, Date(1982, 1, 4)) == Date(1982, 1, 4));
assert(min(Date.min, Date.max) == Date.min);
assert(min(Date.max, Date.min) == Date.min);
@paramargs The values to select the minimum from. At least two arguments must be passed, and they must be comparable with <.@returnsThe minimum of the passed-in values. The type of the returned value is the type among the passed arguments that is able to store the smallest value. If at least one of the arguments is NaN, the result is an unspecified value. See minElement for examples on how to cope with NaNs.@seeminElement
min
(
(parameter) const(sparkles.test_runner.tier0.Tier0Stats) t
t
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
,
(parameter) const(sparkles.test_runner.tier0.Tier0Stats) t
t
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
) /
(parameter) const(sparkles.test_runner.tier0.Tier0Stats) t
t
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
) * 100 : double.
(constant) double double.nan = nan
nan
;
} @("tier0.cacheHitPercent") @safe pure nothrow @nogc unittest { import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isClose = std.math.operations.isClose(T, U, V = CommonType!(FloatingPointBaseType!T, FloatingPointBaseType!U))(T lhs, U rhs, V maxRelDiff = CommonDefaultFor!(T, U), V maxAbsDiff = 0.0)

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Params: lhs = First item to compare. rhs = Second item to compare. maxRelDiff = Maximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type. maxAbsDiff = Maximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.

Returns: true if the two items are approximately equal under either criterium. It is sufficient, when value satisfies one of the two criteria.

       If one item is a range, and the other is a single value, then
       the result is the logical and-ing of calling `isClose` on
       each element of the ranged item against the single item. If
       both items are ranges, then `isClose` returns `true` if
       and only if the ranges have the same number of elements and if
       `isClose` evaluates to `true` for each pair of elements.

    See_Also:
        Use $(LREF feqrel) to get the number of equal bits in the mantissa.
isClose
,
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
assert(
double sparkles.test_runner.tier0.cacheHitPercent(in sparkles.test_runner.tier0.Tier0Stats t) pure nothrow @nogc @safe

Page-cache hit rate in percent: the fraction of bytes served without touching the block device (1 − read_bytes ÷ rchar). nan when nothing was read (or read_bytes is unavailable). A cold read's kernel readahead can pull more from disk than userspace consumed (read_bytes > rchar), so the ratio is clamped to a 0% hit rate rather than reported as nan — the cold case the metric reveals.

cacheHitPercent
(
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(rdChars: 4096, rdBytes: 0)).
bool std.math.operations.isClose!(double, int, real)(double lhs, int rhs, real maxRelDiff = 1e-09L, real maxAbsDiff = 0.0L) pure nothrow @nogc @safe

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Examples

assert(isClose(1.0,0.999_999_999));
assert(isClose(0.001, 0.000_999_999_999));
assert(isClose(1_000_000_000.0,999_999_999.0));

assert(isClose(17.123_456_789, 17.123_456_78));
assert(!isClose(17.123_456_789, 17.123_45));

// use explicit 3rd parameter for less (or more) accuracy
assert(isClose(17.123_456_789, 17.123_45, 1e-6));
assert(!isClose(17.123_456_789, 17.123_45, 1e-7));

// use 4th parameter when comparing close to zero
assert(!isClose(1e-100, 0.0));
assert(isClose(1e-100, 0.0, 0.0, 1e-90));
assert(!isClose(1e-10, -1e-10));
assert(isClose(1e-10, -1e-10, 0.0, 1e-9));
assert(!isClose(1e-300, 1e-298));
assert(isClose(1e-300, 1e-298, 0.0, 1e-200));

// different default limits for different floating point types
assert(isClose(1.0f, 0.999_99f));
assert(!isClose(1.0, 0.999_99));
static if (real.sizeof > double.sizeof)
    assert(!isClose(1.0L, 0.999_999_999L));
assert(isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001]));

assert(isClose([2.0, 1.999_999_999, 2.000_000_001], 2.0));
assert(isClose(2.0, [2.0, 1.999_999_999, 2.000_000_001]));
@paramlhs First item to compare.@paramrhs Second item to compare.@parammaxRelDiff Maximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type.@parammaxAbsDiff Maximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.@returns

true if the two items are approximately equal under either criterium. It is sufficient, when value satisfies one of the two criteria.

If one item is a range, and the other is a single value, then the result is the logical and-ing of calling isClose on each element of the ranged item against the single item. If both items are ranges, then isClose returns true if and only if the ranges have the same number of elements and if isClose evaluates to true for each pair of elements.

@seeUse feqrel to get the number of equal bits in the mantissa.
isClose
(100));
assert(
double sparkles.test_runner.tier0.cacheHitPercent(in sparkles.test_runner.tier0.Tier0Stats t) pure nothrow @nogc @safe

Page-cache hit rate in percent: the fraction of bytes served without touching the block device (1 − read_bytes ÷ rchar). nan when nothing was read (or read_bytes is unavailable). A cold read's kernel readahead can pull more from disk than userspace consumed (read_bytes > rchar), so the ratio is clamped to a 0% hit rate rather than reported as nan — the cold case the metric reveals.

cacheHitPercent
(
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(rdChars: 4096, rdBytes: 1024)).
bool std.math.operations.isClose!(double, int, real)(double lhs, int rhs, real maxRelDiff = 1e-09L, real maxAbsDiff = 0.0L) pure nothrow @nogc @safe

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Examples

assert(isClose(1.0,0.999_999_999));
assert(isClose(0.001, 0.000_999_999_999));
assert(isClose(1_000_000_000.0,999_999_999.0));

assert(isClose(17.123_456_789, 17.123_456_78));
assert(!isClose(17.123_456_789, 17.123_45));

// use explicit 3rd parameter for less (or more) accuracy
assert(isClose(17.123_456_789, 17.123_45, 1e-6));
assert(!isClose(17.123_456_789, 17.123_45, 1e-7));

// use 4th parameter when comparing close to zero
assert(!isClose(1e-100, 0.0));
assert(isClose(1e-100, 0.0, 0.0, 1e-90));
assert(!isClose(1e-10, -1e-10));
assert(isClose(1e-10, -1e-10, 0.0, 1e-9));
assert(!isClose(1e-300, 1e-298));
assert(isClose(1e-300, 1e-298, 0.0, 1e-200));

// different default limits for different floating point types
assert(isClose(1.0f, 0.999_99f));
assert(!isClose(1.0, 0.999_99));
static if (real.sizeof > double.sizeof)
    assert(!isClose(1.0L, 0.999_999_999L));
assert(isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001]));

assert(isClose([2.0, 1.999_999_999, 2.000_000_001], 2.0));
assert(isClose(2.0, [2.0, 1.999_999_999, 2.000_000_001]));
@paramlhs First item to compare.@paramrhs Second item to compare.@parammaxRelDiff Maximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type.@parammaxAbsDiff Maximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.@returns

true if the two items are approximately equal under either criterium. It is sufficient, when value satisfies one of the two criteria.

If one item is a range, and the other is a single value, then the result is the logical and-ing of calling isClose on each element of the ranged item against the single item. If both items are ranges, then isClose returns true if and only if the ranges have the same number of elements and if isClose evaluates to true for each pair of elements.

@seeUse feqrel to get the number of equal bits in the mantissa.
isClose
(75));
// Readahead: read_bytes > rchar → clamp to 0%, not nan. assert(
double sparkles.test_runner.tier0.cacheHitPercent(in sparkles.test_runner.tier0.Tier0Stats t) pure nothrow @nogc @safe

Page-cache hit rate in percent: the fraction of bytes served without touching the block device (1 − read_bytes ÷ rchar). nan when nothing was read (or read_bytes is unavailable). A cold read's kernel readahead can pull more from disk than userspace consumed (read_bytes > rchar), so the ratio is clamped to a 0% hit rate rather than reported as nan — the cold case the metric reveals.

cacheHitPercent
(
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(rdChars: 4096, rdBytes: 8192)).
bool std.math.operations.isClose!(double, int, real)(double lhs, int rhs, real maxRelDiff = 1e-09L, real maxAbsDiff = 0.0L) pure nothrow @nogc @safe

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Examples

assert(isClose(1.0,0.999_999_999));
assert(isClose(0.001, 0.000_999_999_999));
assert(isClose(1_000_000_000.0,999_999_999.0));

assert(isClose(17.123_456_789, 17.123_456_78));
assert(!isClose(17.123_456_789, 17.123_45));

// use explicit 3rd parameter for less (or more) accuracy
assert(isClose(17.123_456_789, 17.123_45, 1e-6));
assert(!isClose(17.123_456_789, 17.123_45, 1e-7));

// use 4th parameter when comparing close to zero
assert(!isClose(1e-100, 0.0));
assert(isClose(1e-100, 0.0, 0.0, 1e-90));
assert(!isClose(1e-10, -1e-10));
assert(isClose(1e-10, -1e-10, 0.0, 1e-9));
assert(!isClose(1e-300, 1e-298));
assert(isClose(1e-300, 1e-298, 0.0, 1e-200));

// different default limits for different floating point types
assert(isClose(1.0f, 0.999_99f));
assert(!isClose(1.0, 0.999_99));
static if (real.sizeof > double.sizeof)
    assert(!isClose(1.0L, 0.999_999_999L));
assert(isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001]));

assert(isClose([2.0, 1.999_999_999, 2.000_000_001], 2.0));
assert(isClose(2.0, [2.0, 1.999_999_999, 2.000_000_001]));
@paramlhs First item to compare.@paramrhs Second item to compare.@parammaxRelDiff Maximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type.@parammaxAbsDiff Maximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.@returns

true if the two items are approximately equal under either criterium. It is sufficient, when value satisfies one of the two criteria.

If one item is a range, and the other is a single value, then the result is the logical and-ing of calling isClose on each element of the ranged item against the single item. If both items are ranges, then isClose returns true if and only if the ranges have the same number of elements and if isClose evaluates to true for each pair of elements.

@seeUse feqrel to get the number of equal bits in the mantissa.
isClose
(0));
// Unknown block-device counter (nan) or nothing read → nan. assert(
double sparkles.test_runner.tier0.cacheHitPercent(in sparkles.test_runner.tier0.Tier0Stats t) pure nothrow @nogc @safe

Page-cache hit rate in percent: the fraction of bytes served without touching the block device (1 − read_bytes ÷ rchar). nan when nothing was read (or read_bytes is unavailable). A cold read's kernel readahead can pull more from disk than userspace consumed (read_bytes > rchar), so the ratio is clamped to a 0% hit rate rather than reported as nan — the cold case the metric reveals.

cacheHitPercent
(
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(rdChars: 4096, rdBytes: double.
(constant) double double.nan = nan
nan
)).
bool std.math.traits.isNaN!double(double x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
);
assert(
double sparkles.test_runner.tier0.cacheHitPercent(in sparkles.test_runner.tier0.Tier0Stats t) pure nothrow @nogc @safe

Page-cache hit rate in percent: the fraction of bytes served without touching the block device (1 − read_bytes ÷ rchar). nan when nothing was read (or read_bytes is unavailable). A cold read's kernel readahead can pull more from disk than userspace consumed (read_bytes > rchar), so the ratio is clamped to a 0% hit rate rather than reported as nan — the cold case the metric reveals.

cacheHitPercent
(
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(rdChars: 0, rdBytes: 0)).
bool std.math.traits.isNaN!double(double x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
);
} /// Finds `key:` at a line start in a `/proc`-style `key:\tvalue` file and parses /// the trailing unsigned integer; `-1` when the key is absent or unparsable. long
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(const(char)[]
(parameter) const(char)[] content
content
, const(char)[]
(parameter) const(char)[] key
key
) @safe pure nothrow @nogc
{
(alias) object.size_t = ulong
size_t
(local variable) ulong i
i
= 0;
while (
(local variable) ulong i
i
<
(parameter) const(char)[] content
content
.
(field) ulong const(char)[].length
length
)
{ if (
(parameter) const(char)[] content
content
.
(field) ulong const(char)[].length
length
-
(local variable) ulong i
i
>
(parameter) const(char)[] key
key
.
(field) ulong const(char)[].length
length
&&
(parameter) const(char)[] content
content
[
(local variable) ulong i
i
..
(local variable) ulong i
i
+
(parameter) const(char)[] key
key
.
(field) ulong const(char)[].length
length
] ==
(parameter) const(char)[] key
key
&&
(parameter) const(char)[] content
content
[
(local variable) ulong i
i
+
(parameter) const(char)[] key
key
.
(field) ulong const(char)[].length
length
] == ':')
{
(alias) object.size_t = ulong
size_t
(local variable) ulong j
j
=
(local variable) ulong i
i
+
(parameter) const(char)[] key
key
.
(field) ulong const(char)[].length
length
+ 1;
while (
(local variable) ulong j
j
<
(parameter) const(char)[] content
content
.
(field) ulong const(char)[].length
length
&& (
(parameter) const(char)[] content
content
[
(local variable) ulong j
j
] == ' ' ||
(parameter) const(char)[] content
content
[
(local variable) ulong j
j
] == '\t'))
(local variable) ulong j
j
++;
long
(local variable) long value
value
= 0;
bool
(local variable) bool any
any
;
while (
(local variable) ulong j
j
<
(parameter) const(char)[] content
content
.
(field) ulong const(char)[].length
length
&&
(parameter) const(char)[] content
content
[
(local variable) ulong j
j
] >= '0' &&
(parameter) const(char)[] content
content
[
(local variable) ulong j
j
] <= '9')
{
(local variable) long value
value
=
(local variable) long value
value
* 10 + (
(parameter) const(char)[] content
content
[
(local variable) ulong j
j
] - '0');
(local variable) ulong j
j
++;
(local variable) bool any
any
= true;
} return
(local variable) bool any
any
?
(local variable) long value
value
: -1;
} while (
(local variable) ulong i
i
<
(parameter) const(char)[] content
content
.
(field) ulong const(char)[].length
length
&&
(parameter) const(char)[] content
content
[
(local variable) ulong i
i
] != '\n')
(local variable) ulong i
i
++;
if (
(local variable) ulong i
i
<
(parameter) const(char)[] content
content
.
(field) ulong const(char)[].length
length
)
(local variable) ulong i
i
++;
} return -1; } @("tier0.parseProcField") @safe pure nothrow @nogc unittest { static immutable
(immutable global) immutable(string) sparkles.test_runner.tier0.__unittest_L116_C1.io
io
= "rchar: 4096\nwchar: 0\nsyscr: 7\nread_bytes: 512\n";
assert(
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(immutable global) immutable(string) sparkles.test_runner.tier0.__unittest_L116_C1.io
io
, "rchar") == 4096);
assert(
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(immutable global) immutable(string) sparkles.test_runner.tier0.__unittest_L116_C1.io
io
, "syscr") == 7);
assert(
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(immutable global) immutable(string) sparkles.test_runner.tier0.__unittest_L116_C1.io
io
, "read_bytes") == 512);
assert(
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(immutable global) immutable(string) sparkles.test_runner.tier0.__unittest_L116_C1.io
io
, "write_bytes") == -1); // absent
assert(
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(immutable global) immutable(string) sparkles.test_runner.tier0.__unittest_L116_C1.io
io
, "char") == -1); // not a line-start key
} /// Divides raw before/after readings into per-iteration `Tier0Stats`; a source /// unavailable in either reading yields `nan` for its fields. package
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.deltaStats(in sparkles.test_runner.tier0.Tier0Reading a, in sparkles.test_runner.tier0.Tier0Reading b, uint iters) pure nothrow @nogc @safe

Divides raw before/after readings into per-iteration Tier0Stats; a source unavailable in either reading yields nan for its fields.

deltaStats
(in
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
, in
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
, uint
(parameter) uint iters
iters
)
@safe pure nothrow @nogc in (
(parameter) uint iters
iters
> 0)
{ const
(local variable) const(double) inv
inv
= 1.0 /
(parameter) uint iters
iters
;
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
;
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) ulong sparkles.test_runner.tier0.Tier0Stats.iters

counting-pass iterations

iters
=
(parameter) uint iters
iters
;
// Per-field guard: a reading whose field is absent (a kernel // omitting/restricting it, or a platform whose libc reports but never // maintains it — XNU's rusage tail leaves ru_nvcsw permanently 0) is // -1, and an absent counter must read nan, never a fabricated 0 delta // (which would also feed a fake 100% cache-hit figure). static double
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(long
(parameter) long av
av
, long
(parameter) long bv
bv
, double
(parameter) double inv
inv
) @safe pure nothrow @nogc
=>
(parameter) long av
av
>= 0 &&
(parameter) long bv
bv
>= 0 ? (
(parameter) long bv
bv
-
(parameter) long av
av
) *
(parameter) double inv
inv
: double.
(constant) double double.nan = nan
nan
;
if (
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) bool sparkles.test_runner.tier0.Tier0Reading.rusageOk
rusageOk
&&
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) bool sparkles.test_runner.tier0.Tier0Reading.rusageOk
rusageOk
)
{
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.minflt

minor page faults per iteration (getrusage)

minflt
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.minflt
minflt
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.minflt
minflt
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.majflt

major page faults per iteration (getrusage)

majflt
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.majflt
majflt
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.majflt
majflt
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.volCs

voluntary context switches per iteration (blocked on I/O)

volCs
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.volCs
volCs
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.volCs
volCs
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.involCs

involuntary context switches per iteration (preempted)

involCs
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.involCs

getrusage

involCs
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.involCs

getrusage

involCs
,
(local variable) const(double) inv
inv
);
} else
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.minflt

minor page faults per iteration (getrusage)

minflt
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.majflt

major page faults per iteration (getrusage)

majflt
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.volCs

voluntary context switches per iteration (blocked on I/O)

volCs
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.involCs

involuntary context switches per iteration (preempted)

involCs
= double.
(constant) double double.nan = nan
nan
;
if (
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) bool sparkles.test_runner.tier0.Tier0Reading.ioOk
ioOk
&&
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) bool sparkles.test_runner.tier0.Tier0Reading.ioOk
ioOk
)
{
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.syscr
syscr
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.syscr
syscr
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.syscw
syscw
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.syscw
syscw
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.rdChars
rdChars
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.rdChars
rdChars
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.wrChars
wrChars
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.wrChars
wrChars
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.rdBytes
rdBytes
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.rdBytes
rdBytes
,
(local variable) const(double) inv
inv
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrBytes

bytes that actually hit the block device (writes)

wrBytes
=
double sparkles.test_runner.tier0.deltaStats.guarded(long av, long bv, double inv) pure nothrow @nogc @safe
guarded
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
.
(field) long sparkles.test_runner.tier0.Tier0Reading.wrBytes

/proc/self/io

wrBytes
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
.
(field) long sparkles.test_runner.tier0.Tier0Reading.wrBytes

/proc/self/io

wrBytes
,
(local variable) const(double) inv
inv
);
} else
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
=
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrBytes

bytes that actually hit the block device (writes)

wrBytes
= double.
(constant) double double.nan = nan
nan
;
return
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
;
} @("tier0.deltaStats.absentBlockDeviceFields") @safe pure nothrow @nogc unittest { import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isClose = std.math.operations.isClose(T, U, V = CommonType!(FloatingPointBaseType!T, FloatingPointBaseType!U))(T lhs, U rhs, V maxRelDiff = CommonDefaultFor!(T, U), V maxAbsDiff = 0.0)

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Params: lhs = First item to compare. rhs = Second item to compare. maxRelDiff = Maximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type. maxAbsDiff = Maximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.

Returns: true if the two items are approximately equal under either criterium. It is sufficient, when value satisfies one of the two criteria.

       If one item is a range, and the other is a single value, then
       the result is the logical and-ing of calling `isClose` on
       each element of the ranged item against the single item. If
       both items are ranges, then `isClose` returns `true` if
       and only if the ranges have the same number of elements and if
       `isClose` evaluates to `true` for each pair of elements.

    See_Also:
        Use $(LREF feqrel) to get the number of equal bits in the mantissa.
isClose
,
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
// A kernel without CONFIG_TASK_IO_ACCOUNTING: rchar/syscr present, read_bytes/ // write_bytes absent (-1) — ioOk is still true. const
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) a
a
=
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
(syscr: 10, syscw: 2, rdChars: 4096, wrChars: 0,
rdBytes: -1, wrBytes: -1, ioOk: true); const
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) b
b
=
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
(syscr: 20, syscw: 4, rdChars: 8192, wrChars: 0,
rdBytes: -1, wrBytes: -1, ioOk: true); const
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
=
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.deltaStats(in sparkles.test_runner.tier0.Tier0Reading a, in sparkles.test_runner.tier0.Tier0Reading b, uint iters) pure nothrow @nogc @safe

Divides raw before/after readings into per-iteration Tier0Stats; a source unavailable in either reading yields nan for its fields.

deltaStats
(
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) a
a
,
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) b
b
, 2);
assert(
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
.
bool std.math.operations.isClose!(const(double), int, real)(const(double) lhs, int rhs, real maxRelDiff = 1e-09L, real maxAbsDiff = 0.0L) pure nothrow @nogc @safe

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Examples

assert(isClose(1.0,0.999_999_999));
assert(isClose(0.001, 0.000_999_999_999));
assert(isClose(1_000_000_000.0,999_999_999.0));

assert(isClose(17.123_456_789, 17.123_456_78));
assert(!isClose(17.123_456_789, 17.123_45));

// use explicit 3rd parameter for less (or more) accuracy
assert(isClose(17.123_456_789, 17.123_45, 1e-6));
assert(!isClose(17.123_456_789, 17.123_45, 1e-7));

// use 4th parameter when comparing close to zero
assert(!isClose(1e-100, 0.0));
assert(isClose(1e-100, 0.0, 0.0, 1e-90));
assert(!isClose(1e-10, -1e-10));
assert(isClose(1e-10, -1e-10, 0.0, 1e-9));
assert(!isClose(1e-300, 1e-298));
assert(isClose(1e-300, 1e-298, 0.0, 1e-200));

// different default limits for different floating point types
assert(isClose(1.0f, 0.999_99f));
assert(!isClose(1.0, 0.999_99));
static if (real.sizeof > double.sizeof)
    assert(!isClose(1.0L, 0.999_999_999L));
assert(isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001]));

assert(isClose([2.0, 1.999_999_999, 2.000_000_001], 2.0));
assert(isClose(2.0, [2.0, 1.999_999_999, 2.000_000_001]));
@paramlhs First item to compare.@paramrhs Second item to compare.@parammaxRelDiff Maximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type.@parammaxAbsDiff Maximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.@returns

true if the two items are approximately equal under either criterium. It is sufficient, when value satisfies one of the two criteria.

If one item is a range, and the other is a single value, then the result is the logical and-ing of calling isClose on each element of the ranged item against the single item. If both items are ranges, then isClose returns true if and only if the ranges have the same number of elements and if isClose evaluates to true for each pair of elements.

@seeUse feqrel to get the number of equal bits in the mantissa.
isClose
(5) &&
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
.
bool std.math.operations.isClose!(const(double), int, real)(const(double) lhs, int rhs, real maxRelDiff = 1e-09L, real maxAbsDiff = 0.0L) pure nothrow @nogc @safe

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

Examples

assert(isClose(1.0,0.999_999_999));
assert(isClose(0.001, 0.000_999_999_999));
assert(isClose(1_000_000_000.0,999_999_999.0));

assert(isClose(17.123_456_789, 17.123_456_78));
assert(!isClose(17.123_456_789, 17.123_45));

// use explicit 3rd parameter for less (or more) accuracy
assert(isClose(17.123_456_789, 17.123_45, 1e-6));
assert(!isClose(17.123_456_789, 17.123_45, 1e-7));

// use 4th parameter when comparing close to zero
assert(!isClose(1e-100, 0.0));
assert(isClose(1e-100, 0.0, 0.0, 1e-90));
assert(!isClose(1e-10, -1e-10));
assert(isClose(1e-10, -1e-10, 0.0, 1e-9));
assert(!isClose(1e-300, 1e-298));
assert(isClose(1e-300, 1e-298, 0.0, 1e-200));

// different default limits for different floating point types
assert(isClose(1.0f, 0.999_99f));
assert(!isClose(1.0, 0.999_99));
static if (real.sizeof > double.sizeof)
    assert(!isClose(1.0L, 0.999_999_999L));
assert(isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0], [0.999_999_999, 2.000_000_001, 3.0]));
assert(!isClose([1.0, 2.0, 3.0], [0.999_999_999, 2.000_000_001]));

assert(isClose([2.0, 1.999_999_999, 2.000_000_001], 2.0));
assert(isClose(2.0, [2.0, 1.999_999_999, 2.000_000_001]));
@paramlhs First item to compare.@paramrhs Second item to compare.@parammaxRelDiff Maximum allowable relative difference. Setting to 0.0 disables this check. Default depends on the type of lhs and rhs: It is approximately half the number of decimal digits of precision of the smaller type.@parammaxAbsDiff Maximum absolute difference. This is mainly usefull for comparing values to zero. Setting to 0.0 disables this check. Defaults to 0.0.@returns

true if the two items are approximately equal under either criterium. It is sufficient, when value satisfies one of the two criteria.

If one item is a range, and the other is a single value, then the result is the logical and-ing of calling isClose on each element of the ranged item against the single item. If both items are ranges, then isClose returns true if and only if the ranges have the same number of elements and if isClose evaluates to true for each pair of elements.

@seeUse feqrel to get the number of equal bits in the mantissa.
isClose
(2048));
assert(
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
.
bool std.math.traits.isNaN!(const(double))(const(double) x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
&&
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrBytes

bytes that actually hit the block device (writes)

wrBytes
.
bool std.math.traits.isNaN!(const(double))(const(double) x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
, "absent block-device fields → nan");
assert(
double sparkles.test_runner.tier0.cacheHitPercent(in sparkles.test_runner.tier0.Tier0Stats t) pure nothrow @nogc @safe

Page-cache hit rate in percent: the fraction of bytes served without touching the block device (1 − read_bytes ÷ rchar). nan when nothing was read (or read_bytes is unavailable). A cold read's kernel readahead can pull more from disk than userspace consumed (read_bytes > rchar), so the ratio is clamped to a 0% hit rate rather than reported as nan — the cold case the metric reveals.

cacheHitPercent
(
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
).
bool std.math.traits.isNaN!double(double x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
, "cache-hit unknown when read_bytes absent");
} /// A single instant's raw cumulative counters. struct
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
{ long
(field) long sparkles.test_runner.tier0.Tier0Reading.minflt
minflt
,
(field) long sparkles.test_runner.tier0.Tier0Reading.majflt
majflt
,
(field) long sparkles.test_runner.tier0.Tier0Reading.volCs
volCs
,
(field) long sparkles.test_runner.tier0.Tier0Reading.involCs

getrusage

involCs
; /// getrusage
long
(field) long sparkles.test_runner.tier0.Tier0Reading.syscr
syscr
,
(field) long sparkles.test_runner.tier0.Tier0Reading.syscw
syscw
,
(field) long sparkles.test_runner.tier0.Tier0Reading.rdChars
rdChars
,
(field) long sparkles.test_runner.tier0.Tier0Reading.wrChars
wrChars
,
(field) long sparkles.test_runner.tier0.Tier0Reading.rdBytes
rdBytes
,
(field) long sparkles.test_runner.tier0.Tier0Reading.wrBytes

/proc/self/io

wrBytes
; /// /proc/self/io
bool
(field) bool sparkles.test_runner.tier0.Tier0Reading.rusageOk
rusageOk
,
(field) bool sparkles.test_runner.tier0.Tier0Reading.ioOk
ioOk
;
} version (
linux
linux
)
{ import
(package) core
core
.
(package) core.sys
sys
.
(package) core.sys.posix
posix
.
(package) core.sys.posix.sys
sys
.
(module) core.sys.posix.sys.resource

D header file for POSIX.

@copyrightCopyright (c) 2013 Lars Tandle Kyllingstad.@licenseBoost License 1.0.@authorsLars Tandle Kyllingstad@standardsThe Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008
resource
:
(alias) sparkles.test_runner.tier0.getrusage = int core.sys.posix.sys.resource.getrusage(int, core.sys.posix.sys.resource.rusage*) nothrow @nogc
getrusage
,
(struct) core.sys.posix.sys.resource.rusage
rusage
,
(alias enum value) sparkles.test_runner.tier0.RUSAGE_SELF = core.sys.posix.sys.resource.RUSAGE_SELF = 0
RUSAGE_SELF
;
/// The Tier-0 counter group. No fds; `count` snapshots the cumulative /// counters around each iteration. Carries the calibrated per-bracket /// self-cost of the snapshots themselves (see `calibrateSelfCost`). struct
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
{ private bool
(field) bool sparkles.test_runner.tier0.Tier0Group.enabled
enabled
;
private
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
; /// per-bracket snapshot cost; 0 = uncalibrated
/// Whether Tier-0 counters will be collected (Linux and requested). bool
bool sparkles.test_runner.tier0.Tier0Group.available() const pure nothrow @nogc @safe

Whether Tier-0 counters will be collected (Linux and requested).

available
() const @safe pure nothrow @nogc =>
(field) bool sparkles.test_runner.tier0.Tier0Group.enabled
enabled
;
/// Human-readable availability, for a report header.
(alias) object.string = string
string
string sparkles.test_runner.tier0.Tier0Group.status() const pure nothrow @safe

Human-readable availability, for a report header.

status
() const @safe pure nothrow
=>
(field) bool sparkles.test_runner.tier0.Tier0Group.enabled
enabled
? "getrusage + /proc/self/io" : "not requested";
/// What this backend can deliver: process-scope resource counting — /// present whenever requested (Linux needs no privilege for it).
(struct) sparkles.test_runner.capability.CapabilityReport

What a backend can deliver on this host, this run: the present flags OR-ed together, and a reasoned entry per absent flag (in allCapabilities order). A flag mentioned in neither is outside the backend's domain.

CapabilityReport
sparkles.test_runner.capability.CapabilityReport sparkles.test_runner.tier0.Tier0Group.capabilities() const pure nothrow @nogc @safe

What this backend can deliver: process-scope resource counting — present whenever requested (Linux needs no privilege for it).

capabilities
() const @safe pure nothrow @nogc
=>
(field) bool sparkles.test_runner.tier0.Tier0Group.enabled
enabled
?
(struct) sparkles.test_runner.capability.CapabilityReport

What a backend can deliver on this host, this run: the present flags OR-ed together, and a reasoned entry per absent flag (in allCapabilities order). A flag mentioned in neither is outside the backend's domain.

CapabilityReport
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.counting = 1u

concern 1: scalar counting

counting
, null)
:
(struct) sparkles.test_runner.capability.CapabilityReport

What a backend can deliver on this host, this run: the present flags OR-ed together, and a reasoned entry per absent flag (in allCapabilities order). A flag mentioned in neither is outside the backend's domain.

CapabilityReport
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.none = 0u
none
,
(immutable global) immutable(sparkles.test_runner.capability.CapabilityAbsence[1]) sparkles.test_runner.tier0.Tier0Group.notRequestedAbsence
notRequestedAbsence
[]);
private static immutable
(struct) sparkles.test_runner.capability.CapabilityAbsence

One absent capability with its host-grounded reason.

CapabilityAbsence
[1]
(immutable global) immutable(sparkles.test_runner.capability.CapabilityAbsence[1]) sparkles.test_runner.tier0.Tier0Group.notRequestedAbsence
notRequestedAbsence
= [
(struct) sparkles.test_runner.capability.CapabilityAbsence

One absent capability with its host-grounded reason.

CapabilityAbsence
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.counting = 1u

concern 1: scalar counting

counting
, "not requested"),
]; /// Enables collection when `enabled` and calibrates the snapshot /// self-cost; otherwise an unavailable group (mirrors /// `PerfGroup.tryOpen(false)`), so the same call sites work. static
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
sparkles.test_runner.tier0.Tier0Group sparkles.test_runner.tier0.Tier0Group.tryOpen(bool enabled) @safe

Enables collection when enabled and calibrates the snapshot self-cost; otherwise an unavailable group (mirrors PerfGroup.tryOpen(false)), so the same call sites work.

tryOpen
(bool
(parameter) bool enabled
enabled
) @safe
{ auto
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
=
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
(
(parameter) bool enabled
enabled
);
if (
(parameter) bool enabled
enabled
)
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
.
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
=
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
.
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost() @safe

The per-bracket cost of the bracketing snapshots themselves: each start/end pair puts one /proc/self/io read (~1 syscr, a few hundred rchar bytes) inside its own window. Measured as the median of several empty brackets so count can subtract it. Page-fault and context-switch fields stay 0 — they carry no steady-state bracket cost, and subtracting sporadic noise would bias real counts.

calibrateSelfCost
();
return
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
;
} /// The per-bracket cost of the bracketing snapshots themselves: each /// `start`/`end` pair puts one `/proc/self/io` read (~1 `syscr`, a few /// hundred `rchar` bytes) inside its own window. Measured as the median /// of several empty brackets so `count` can subtract it. Page-fault and /// context-switch fields stay 0 — they carry no steady-state bracket /// cost, and subtracting sporadic noise would bias real counts. private
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost() @safe

The per-bracket cost of the bracketing snapshots themselves: each start/end pair puts one /proc/self/io read (~1 syscr, a few hundred rchar bytes) inside its own window. Measured as the median of several empty brackets so count can subtract it. Page-fault and context-switch fields stay 0 — they carry no steady-state bracket cost, and subtracting sporadic noise would bias real counts.

calibrateSelfCost
() @safe
{ import
(package) std
std
.
(package) std.algorithm
algorithm
.
(module) std.algorithm.sorting

This is a submodule of std.algorithm. It contains generic sorting algorithms.

Function Name Description
completeSort If a = [10, 20, 30] and b = [40, 6, 15], then completeSort(a, b) leaves a = [6, 10, 15] and b = [20, 30, 40]. The range a must be sorted prior to the call, and as a result the combination ``chain(a, b) is sorted.
isPartitioned isPartitioned!"a < 0"([-1, -2, 1, 0, 2]) returns true because the predicate is true for a portion of the range and false afterwards.
isSorted isSorted([1, 1, 2, 3]) returns true.
isStrictlyMonotonic isStrictlyMonotonic([1, 1, 2, 3]) returns false.
ordered ordered(1, 1, 2, 3) returns true.
strictlyOrdered strictlyOrdered(1, 1, 2, 3) returns false.
makeIndex Creates a separate index for a range.
merge Lazily merges two or more sorted ranges.
multiSort Sorts by multiple keys.
nextEvenPermutation Computes the next lexicographically greater even permutation of a range in-place.
nextPermutation Computes the next lexicographically greater permutation of a range in-place.
nthPermutation Computes the nth permutation of a range in-place.
partialSort If a = [5, 4, 3, 2, 1], then partialSort(a, 3) leaves a[0 .. 3] = [1, 2, 3]. The other elements of a are left in an unspecified order.
partition Partitions a range according to a unary predicate.
partition3 Partitions a range according to a binary predicate in three parts (less than, equal, greater than the given pivot). Pivot is not given as an index, but instead as an element independent from the range's content.
pivotPartition Partitions a range according to a binary predicate in two parts: less than or equal, and greater than or equal to the given pivot, passed as an index in the range.
schwartzSort Sorts with the help of the Schwartzian transform.
sort Sorts.
topN Separates the top elements in a range, akin to Quickselect.
topNCopy Copies out the top elements of a range.
topNIndex Builds an index of the top elements of a range.

Source

std/algorithm/sorting.d

@copyrightAndrei Alexandrescu 2008-.@licenseBoost License 1.0.@authorsAndrei Alexandrescu
sorting
:
(alias template) sort = std.algorithm.sorting.sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r)

Sorts a random-access range according to the predicate less.

Performs $(BIGOH r.length * log(r.length)) evaluations of `less`. If `less` involves expensive computations on the _sort key, it may be worthwhile to use $(LREF schwartzSort) instead.

Stable sorting requires hasAssignableElements!Range to be true.

sort returns a $(REF SortedRange, std,range) over the original range, allowing functions that can take advantage of sorted data to know that the range is sorted and adjust accordingly. The $(REF SortedRange, std,range) is a wrapper around the original range, so both it and the original range are sorted. Other functions can't know that the original range has been sorted, but they $(I can) know that $(REF SortedRange, std,range) has been sorted.

Preconditions:

The predicate is expected to satisfy certain rules in order for sort to behave as expected - otherwise, the program may fail on certain inputs (but not others) when not compiled in release mode, due to the cursory assumeSorted check. Specifically, sort expects less(a,b) && less(b,c) to imply less(a,c) (transitivity), and, conversely, !less(a,b) && !less(b,c) to imply !less(a,c). Note that the default predicate ("a < b") does not always satisfy these conditions for floating point types, because the expression will always be false when either a or b is NaN. Use $(REF cmp, std,math) instead.

Params: less = The predicate to sort by. ss = The swapping strategy to use. r = The range to sort.

Returns: The initial range wrapped as a SortedRange with the predicate binaryFun!less.

Algorithms: $(HTTP en.wikipedia.org/wiki/Introsort, Introsort) is used for unstable sorting and $(HTTP en.wikipedia.org/wiki/Timsort, Timsort) is used for stable sorting. Each algorithm has benefits beyond stability. Introsort is generally faster but Timsort may achieve greater speeds on data with low entropy or if predicate calls are expensive. Introsort performs no allocations whereas Timsort will perform one or more allocations per call. Both algorithms have $(BIGOH n log n) worst-case time complexity.

See_Also: $(REF assumeSorted, std,range)$(BR) $(REF SortedRange, std,range)$(BR) $(REF SwapStrategy, std,algorithm,mutation)$(BR) $(REF binaryFun, std,functional)

sort
;
import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
enum
(constant) int sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.rounds = 9
rounds
= 9;
double[
(constant) int sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.rounds = 9
rounds
]
(local variable) double[9] syscr
syscr
,
(local variable) double[9] syscw
syscw
,
(local variable) double[9] rdChars
rdChars
,
(local variable) double[9] wrChars
wrChars
;
foreach (
(local variable) int i
i
; 0 ..
(constant) int sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.rounds = 9
rounds
)
{ const
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
=
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.deltaStats(in sparkles.test_runner.tier0.Tier0Reading a, in sparkles.test_runner.tier0.Tier0Reading b, uint iters) pure nothrow @nogc @safe

Divides raw before/after readings into per-iteration Tier0Stats; a source unavailable in either reading yields nan for its fields.

deltaStats
(
sparkles.test_runner.tier0.Tier0Reading sparkles.test_runner.tier0.Tier0Group.snapshot() nothrow @nogc @safe

Reads the cumulative counters now.

snapshot
(),
sparkles.test_runner.tier0.Tier0Reading sparkles.test_runner.tier0.Tier0Group.snapshot() nothrow @nogc @safe

Reads the cumulative counters now.

snapshot
(), 1);
(local variable) double[9] syscr
syscr
[
(local variable) int i
i
] =
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
;
(local variable) double[9] syscw
syscw
[
(local variable) int i
i
] =
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
;
(local variable) double[9] rdChars
rdChars
[
(local variable) int i
i
] =
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
;
(local variable) double[9] wrChars
wrChars
[
(local variable) int i
i
] =
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
;
} static double
double sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.med(double[] v) pure nothrow @nogc @safe
med
(double[]
(parameter) double[] v
v
) @safe
{ if (
(parameter) double[] v
v
[0].
bool std.math.traits.isNaN!double(double x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
)
return 0; // source unavailable — nothing to subtract
(parameter) double[] v
v
.
std.range.SortedRange!(double[], "a < b", SortedRangeOptions.assumeSorted) std.algorithm.sorting.sort!("a < b", SwapStrategy.unstable, double[])(double[] r) pure nothrow @nogc @safe

Sorts a random-access range according to the predicate less.

Performs O(r.length * log(r.length)) evaluations of less. If less involves expensive computations on the sort key, it may be worthwhile to use schwartzSort instead.

Stable sorting requires hasAssignableElements!Range to be true.

sort returns a SortedRange over the original range, allowing functions that can take advantage of sorted data to know that the range is sorted and adjust accordingly. The SortedRange is a wrapper around the original range, so both it and the original range are sorted. Other functions can't know that the original range has been sorted, but they can know that SortedRange has been sorted.

Preconditions

The predicate is expected to satisfy certain rules in order for sort to behave as expected - otherwise, the program may fail on certain inputs (but not others) when not compiled in release mode, due to the cursory assumeSorted check. Specifically, sort expects less(a,b) && less(b,c) to imply less(a,c) (transitivity), and, conversely, !less(a,b) && !less(b,c) to imply !less(a,c). Note that the default predicate ("a < b") does not always satisfy these conditions for floating point types, because the expression will always be false when either a or b is NaN. Use cmp instead.

Algorithms

Introsort is used for unstable sorting and Timsort is used for stable sorting. Each algorithm has benefits beyond stability. Introsort is generally faster but Timsort may achieve greater speeds on data with low entropy or if predicate calls are expensive. Introsort performs no allocations whereas Timsort will perform one or more allocations per call. Both algorithms have O(n log n) worst-case time complexity.

Examples

int[] array = [ 1, 2, 3, 4 ];

// sort in descending order
array.sort!("a > b");
assert(array == [ 4, 3, 2, 1 ]);

// sort in ascending order
array.sort();
assert(array == [ 1, 2, 3, 4 ]);

// sort with reusable comparator and chain
alias myComp = (x, y) => x > y;
assert(array.sort!(myComp).release == [ 4, 3, 2, 1 ]);
// Showcase stable sorting
import std.algorithm.mutation : SwapStrategy;
string[] words = [ "aBc", "a", "abc", "b", "ABC", "c" ];
sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable)(words);
assert(words == [ "a", "aBc", "abc", "ABC", "b", "c" ]);
// Sorting floating-point numbers in presence of NaN
double[] numbers = [-0.0, 3.0, -2.0, double.nan, 0.0, -double.nan];

import std.algorithm.comparison : equal;
import std.math.operations : cmp;
import std.math.traits : isIdentical;

sort!((a, b) => cmp(a, b) < 0)(numbers);

double[] sorted = [-double.nan, -2.0, -0.0, 0.0, 3.0, double.nan];
assert(numbers.equal!isIdentical(sorted));
@paramless The predicate to sort by.@paramss The swapping strategy to use.@paramr The range to sort.@returnsThe initial range wrapped as a SortedRange with the predicate binaryFun!less.@see

assumeSorted

SortedRange

SwapStrategy

binaryFun

sort
;
return
(parameter) double[] v
v
[$ / 2];
}
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(local variable) sparkles.test_runner.tier0.Tier0Stats cost
cost
;
(local variable) sparkles.test_runner.tier0.Tier0Stats cost
cost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
=
double sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.med(double[] v) pure nothrow @nogc @safe
med
(
(local variable) double[9] syscr
syscr
[]);
(local variable) sparkles.test_runner.tier0.Tier0Stats cost
cost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
=
double sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.med(double[] v) pure nothrow @nogc @safe
med
(
(local variable) double[9] syscw
syscw
[]);
(local variable) sparkles.test_runner.tier0.Tier0Stats cost
cost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
=
double sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.med(double[] v) pure nothrow @nogc @safe
med
(
(local variable) double[9] rdChars
rdChars
[]);
(local variable) sparkles.test_runner.tier0.Tier0Stats cost
cost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
=
double sparkles.test_runner.tier0.Tier0Group.calibrateSelfCost.med(double[] v) pure nothrow @nogc @safe
med
(
(local variable) double[9] wrChars
wrChars
[]);
return
(local variable) sparkles.test_runner.tier0.Tier0Stats cost
cost
;
} /// Nothing to release; present for surface parity with `PerfGroup`. void
void sparkles.test_runner.tier0.Tier0Group.close() pure nothrow @nogc @safe

Nothing to release; present for surface parity with PerfGroup.

close
() @safe pure nothrow @nogc {}
/// Reads the cumulative counters now.
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
sparkles.test_runner.tier0.Tier0Reading sparkles.test_runner.tier0.Tier0Group.snapshot() nothrow @nogc @safe

Reads the cumulative counters now.

snapshot
() @safe nothrow @nogc
{
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
;
(struct) core.sys.posix.sys.resource.rusage
rusage
(local variable) core.sys.posix.sys.resource.rusage ru
ru
;
if ((() @trusted =>
int core.sys.posix.sys.resource.getrusage(int, core.sys.posix.sys.resource.rusage*) nothrow @nogc
getrusage
(
(enum value) core.sys.posix.sys.resource.RUSAGE_SELF = 0
RUSAGE_SELF
, &
(local variable) core.sys.posix.sys.resource.rusage ru
ru
))() == 0)
{
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.minflt
minflt
=
(local variable) core.sys.posix.sys.resource.rusage ru
ru
.
(field) long core.sys.posix.sys.resource.rusage.ru_minflt
ru_minflt
;
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.majflt
majflt
=
(local variable) core.sys.posix.sys.resource.rusage ru
ru
.
(field) long core.sys.posix.sys.resource.rusage.ru_majflt
ru_majflt
;
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.volCs
volCs
=
(local variable) core.sys.posix.sys.resource.rusage ru
ru
.
(field) long core.sys.posix.sys.resource.rusage.ru_nvcsw
ru_nvcsw
;
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.involCs

getrusage

involCs
=
(local variable) core.sys.posix.sys.resource.rusage ru
ru
.
(field) long core.sys.posix.sys.resource.rusage.ru_nivcsw
ru_nivcsw
;
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) bool sparkles.test_runner.tier0.Tier0Reading.rusageOk
rusageOk
= true;
} char[1024]
(local variable) char[1024] buf
buf
= void;
const
(local variable) const(char[]) io
io
=
char[] sparkles.test_runner.tier0.readProcSelfIo(return scope char[] buf) nothrow @nogc @safe

Reads /proc/self/io into buf via a raw open/read/close; returns the filled slice (empty on failure). std.file reports size 0 for /proc, so a direct read is required.

readProcSelfIo
(
(local variable) char[1024] buf
buf
[]);
if (
(local variable) const(char[]) io
io
.
(field) ulong const(char[]).length
length
)
{
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.syscr
syscr
=
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(local variable) const(char[]) io
io
, "syscr");
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.syscw
syscw
=
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(local variable) const(char[]) io
io
, "syscw");
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.rdChars
rdChars
=
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(local variable) const(char[]) io
io
, "rchar");
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.wrChars
wrChars
=
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(local variable) const(char[]) io
io
, "wchar");
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.rdBytes
rdBytes
=
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(local variable) const(char[]) io
io
, "read_bytes");
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.wrBytes

/proc/self/io

wrBytes
=
long sparkles.test_runner.tier0.parseProcField(const(char)[] content, const(char)[] key) pure nothrow @nogc @safe

Finds key`:` at a line start in a `/proc`-style key:\tvalue file and parses the trailing unsigned integer; -1 when the key is absent or unparsable.

parseProcField
(
(local variable) const(char[]) io
io
, "write_bytes");
// A field the kernel omits (older kernels, restricted) reads -1; // treat the source as usable iff the always-present counts are.
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) bool sparkles.test_runner.tier0.Tier0Reading.ioOk
ioOk
=
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.syscr
syscr
>= 0 &&
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
.
(field) long sparkles.test_runner.tier0.Tier0Reading.rdChars
rdChars
>= 0;
} return
(local variable) sparkles.test_runner.tier0.Tier0Reading r
r
;
} /// The counting pass: brackets each `timed()` call with its own pair of /// snapshots so `between()` runs outside the counted window, sums the /// per-call deltas, and averages once. Returns per-iteration deltas; an /// unavailable source reads `nan` (it propagates through the sum). /// `batch` brackets that many iterations per snapshot pair, so the two /// `/proc` reads amortize instead of dominating a fast body (the tier-0 /// analogue of the perf bracket's ioctl cost). Only sound when /// `between` is a no-op — the batched rows — so per-call rows keep /// `batch == 1`, where this is the original per-iteration loop.
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.count!(void function() pure nothrow @nogc @safe, void function() nothrow @nogc @safe)(scope void function() pure nothrow @nogc @safe timed, scope void function() nothrow @nogc @safe between, uint iters, uint batch = 1u) nothrow @nogc @safe

The counting pass: brackets each timed`()` call with its own pair of snapshots so between() runs outside the counted window, sums the per-call deltas, and averages once. Returns per-iteration deltas; an unavailable source reads nan (it propagates through the sum). batch brackets that many iterations per snapshot pair, so the two /proc reads amortize instead of dominating a fast body (the tier-0 analogue of the perf bracket's ioctl cost). Only sound when between is a no-op — the batched rows — so per-call rows keep ``batch == 1, where this is the original per-iteration loop.

count
(Timed, Between)(scope
(alias) Timed = void function() pure nothrow @nogc @safe
Timed
(parameter) void function() pure nothrow @nogc @safe timed
timed
, scope
(alias) Between = void function() nothrow @nogc @safe
Between
(parameter) void function() nothrow @nogc @safe between
between
,
uint
(parameter) uint iters
iters
, uint
(parameter) uint batch
batch
= 1)
in (
(parameter) uint iters
iters
> 0)
{
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
; // running sum of raw deltas (nan propagates)
const
(local variable) const(uint) k
k
=
(parameter) uint batch
batch
== 0 ? 1 :
(parameter) uint batch
batch
;
uint
(local variable) uint done
done
,
(local variable) uint brackets
brackets
;
while (
(local variable) uint done
done
<
(parameter) uint iters
iters
)
{ const
(local variable) const(uint) n
n
=
(local variable) const(uint) k
k
<
(parameter) uint iters
iters
-
(local variable) uint done
done
?
(local variable) const(uint) k
k
:
(parameter) uint iters
iters
-
(local variable) uint done
done
;
(local variable) uint done
done
+=
(local variable) const(uint) n
n
;
++
(local variable) uint brackets
brackets
;
const
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) start
start
=
sparkles.test_runner.tier0.Tier0Reading sparkles.test_runner.tier0.Tier0Group.snapshot() nothrow @nogc @safe

Reads the cumulative counters now.

snapshot
();
foreach (
(local variable) uint _
_
; 0 ..
(local variable) const(uint) n
n
)
(parameter) void function() pure nothrow @nogc @safe timed
timed
();
const
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) end
end
=
sparkles.test_runner.tier0.Tier0Reading sparkles.test_runner.tier0.Tier0Group.snapshot() nothrow @nogc @safe

Reads the cumulative counters now.

snapshot
();
foreach (
(local variable) uint _
_
; 0 ..
(local variable) const(uint) n
n
)
(parameter) void function() nothrow @nogc @safe between
between
(); // untimed teardown, outside the start..end window
// Raw (divisor 1): `sum` accumulates the whole pass's counts, // which the `1/iters` below turns into a per-iteration average // — correct for any batch size. const
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
=
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.deltaStats(in sparkles.test_runner.tier0.Tier0Reading a, in sparkles.test_runner.tier0.Tier0Reading b, uint iters) pure nothrow @nogc @safe

Divides raw before/after readings into per-iteration Tier0Stats; a source unavailable in either reading yields nan for its fields.

deltaStats
(
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) start
start
,
(local variable) const(sparkles.test_runner.tier0.Tier0Reading) end
end
, 1);
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.minflt

minor page faults per iteration (getrusage)

minflt
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.minflt

minor page faults per iteration (getrusage)

minflt
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.majflt

major page faults per iteration (getrusage)

majflt
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.majflt

major page faults per iteration (getrusage)

majflt
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.volCs

voluntary context switches per iteration (blocked on I/O)

volCs
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.volCs

voluntary context switches per iteration (blocked on I/O)

volCs
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.involCs

involuntary context switches per iteration (preempted)

involCs
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.involCs

involuntary context switches per iteration (preempted)

involCs
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrBytes

bytes that actually hit the block device (writes)

wrBytes
+=
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) one
one
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrBytes

bytes that actually hit the block device (writes)

wrBytes
;
} const
(local variable) const(double) inv
inv
= 1.0 /
(parameter) uint iters
iters
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) ulong sparkles.test_runner.tier0.Tier0Stats.iters

counting-pass iterations

iters
=
(parameter) uint iters
iters
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.minflt

minor page faults per iteration (getrusage)

minflt
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.majflt

major page faults per iteration (getrusage)

majflt
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.volCs

voluntary context switches per iteration (blocked on I/O)

volCs
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.involCs

involuntary context switches per iteration (preempted)

involCs
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdBytes

bytes that actually hit the block device (reads)

rdBytes
*=
(local variable) const(double) inv
inv
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrBytes

bytes that actually hit the block device (writes)

wrBytes
*=
(local variable) const(double) inv
inv
;
// Net of the brackets' own snapshot cost (calibrated at open): // without this a no-I/O body reads ~1 syscr and a few hundred // rchar bytes per iteration, and `cacheHitPercent`'s "nothing was // read → nan" branch is unreachable (rchar always > 0). // // The calibration is the cost of ONE bracket, and `sum` is now // per-iteration — so the amount to remove is one bracket's cost // spread over the iterations it covered. At `batch == 1` that is // `brackets == iters` and the factor is 1 (the original behaviour); // batching lowers it, because a batched pass really does pay the // snapshot cost fewer times. const
(local variable) const(double) costShare
costShare
= double(
(local variable) uint brackets
brackets
) /
(parameter) uint iters
iters
;
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
*
(local variable) const(double) costShare
costShare
);
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
*
(local variable) const(double) costShare
costShare
);
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
*
(local variable) const(double) costShare
costShare
);
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
*
(local variable) const(double) costShare
costShare
);
return
(local variable) sparkles.test_runner.tier0.Tier0Stats sum
sum
;
} /// The tier-0 deltas across one window, as window $(B totals) /// (`iters = 1`), net of a single bracket's calibrated snapshot cost.
(struct) sparkles.test_runner.tier0.Tier0Stats

Per-iteration Tier-0 counter deltas of one counting pass. A field is nan when its source could not be read on this machine.

Tier0Stats
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.windowStats(in sparkles.test_runner.tier0.Tier0Reading a, in sparkles.test_runner.tier0.Tier0Reading b) const pure nothrow @nogc @safe

The tier-0 deltas across one window, as window totals (iters = 1), net of a single bracket's calibrated snapshot cost.

windowStats
(in
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
, in
(struct) sparkles.test_runner.tier0.Tier0Reading

A single instant's raw cumulative counters.

Tier0Reading
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
)
const @safe pure nothrow @nogc { auto
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
=
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.deltaStats(in sparkles.test_runner.tier0.Tier0Reading a, in sparkles.test_runner.tier0.Tier0Reading b, uint iters) pure nothrow @nogc @safe

Divides raw before/after readings into per-iteration Tier0Stats; a source unavailable in either reading yields nan for its fields.

deltaStats
(
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) a
a
,
(parameter) const(sparkles.test_runner.tier0.Tier0Reading) b
b
, 1);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.rdChars

bytes read through the syscall layer (cache included)

rdChars
);
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
=
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
,
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.wrChars

bytes written through the syscall layer

wrChars
);
return
(local variable) sparkles.test_runner.tier0.Tier0Stats s
s
;
} } /// Reads `/proc/self/io` into `buf` via a raw `open`/`read`/`close`; returns /// the filled slice (empty on failure). `std.file` reports size 0 for `/proc`, /// so a direct read is required. private char[]
char[] sparkles.test_runner.tier0.readProcSelfIo(return scope char[] buf) nothrow @nogc @safe

Reads /proc/self/io into buf via a raw open/read/close; returns the filled slice (empty on failure). std.file reports size 0 for /proc, so a direct read is required.

readProcSelfIo
(return scope char[]
(parameter) char[] buf
buf
) @safe nothrow @nogc
{ import
(package) core
core
.
(package) core.sys
sys
.
(package) core.sys.posix
posix
.
(module) core.sys.posix.fcntl

D header file for POSIX.

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseBoost License 1.0.@authorsSean Kelly, Alex Rønne Petersen@standardsThe Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
fcntl
: open,
(alias constant) O_RDONLY = int core.sys.posix.fcntl.O_RDONLY = 0
O_RDONLY
;
import
(package) core
core
.
(package) core.sys
sys
.
(package) core.sys.posix
posix
.
(module) core.sys.posix.unistd

D header file for POSIX.

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseBoost License 1.0.@authorsSean Kelly@standardsThe Open Group Base Specifications Issue 8, IEEE Std 1003.1, 2024 Edition
unistd
:
(alias) read = long core.sys.posix.unistd.read(int, void*, ulong) nothrow @nogc
read
,
(alias) close = int core.sys.posix.unistd.close(int) nothrow @nogc @trusted
close
;
const
(local variable) const(int) fd
fd
= (() @trusted => open("/proc/self/io",
(constant) int core.sys.posix.fcntl.O_RDONLY = 0
O_RDONLY
))();
if (
(local variable) const(int) fd
fd
< 0)
return null; scope (exit) (() @trusted =>
int core.sys.posix.unistd.close(int) nothrow @nogc @trusted
close
(
(local variable) const(int) fd
fd
))();
const
(local variable) const(long) n
n
= (() @trusted =>
long core.sys.posix.unistd.read(int, void*, ulong) nothrow @nogc
read
(
(local variable) const(int) fd
fd
,
(parameter) char[] buf
buf
.
(field) char* char[].ptr
ptr
,
(parameter) char[] buf
buf
.
(field) ulong char[].length
length
))();
return
(local variable) const(long) n
n
> 0 ?
(parameter) char[] buf
buf
[0 ..
(local variable) const(long) n
n
] : null;
} @("tier0.Tier0Group.countSmoke") @system unittest { auto
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
=
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
.
sparkles.test_runner.tier0.Tier0Group sparkles.test_runner.tier0.Tier0Group.tryOpen(bool enabled) @safe

Enables collection when enabled and calibrates the snapshot self-cost; otherwise an unavailable group (mirrors PerfGroup.tryOpen(false)), so the same call sites work.

tryOpen
(true);
assert(
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
.
bool sparkles.test_runner.tier0.Tier0Group.available() const pure nothrow @nogc @safe

Whether Tier-0 counters will be collected (Linux and requested).

available
);
// A body that forces at least one write syscall so a count is observable. static void
void sparkles.test_runner.tier0.__unittest_L411_C5.body_() nothrow @nogc @safe
body_
()
{ import
(package) core
core
.
(package) core.sys
sys
.
(package) core.sys.posix
posix
.
(module) core.sys.posix.unistd

D header file for POSIX.

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseBoost License 1.0.@authorsSean Kelly@standardsThe Open Group Base Specifications Issue 8, IEEE Std 1003.1, 2024 Edition
unistd
:
(alias) write = long core.sys.posix.unistd.write(int, scope const(void*), ulong) nothrow @nogc
write
;
char[1]
(local variable) char[1] c
c
= ['x'];
() @trusted {
long core.sys.posix.unistd.write(int, scope const(void*), ulong) nothrow @nogc
write
(2,
(local variable) char[1] c
c
.
(constant) char* char[1].ptr = &c
ptr
, 0); }(); // 0-length write to stderr: a syscall, no output
} const
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
=
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
.
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.count!(void function() nothrow @nogc @safe, void function() pure nothrow @nogc @safe)(scope void function() nothrow @nogc @safe timed, scope void function() pure nothrow @nogc @safe between, uint iters, uint batch = 1u) nothrow @nogc @safe

The counting pass: brackets each timed`()` call with its own pair of snapshots so between() runs outside the counted window, sums the per-call deltas, and averages once. Returns per-iteration deltas; an unavailable source reads nan (it propagates through the sum). batch brackets that many iterations per snapshot pair, so the two /proc reads amortize instead of dominating a fast body (the tier-0 analogue of the perf bracket's ioctl cost). Only sound when between is a no-op — the batched rows — so per-call rows keep ``batch == 1, where this is the original per-iteration loop.

count
(&
void sparkles.test_runner.tier0.__unittest_L411_C5.body_() nothrow @nogc @safe
body_
, () {}, 64);
assert(
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
.
(field) ulong sparkles.test_runner.tier0.Tier0Stats.iters

counting-pass iterations

iters
== 64);
import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
// On a normal Linux host both sources read; syscall count is non-negative. if (!
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
.
bool std.math.traits.isNaN!(const(double))(const(double) x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
)
assert(
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) s
s
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
>= 0);
} @("tier0.Tier0Group.countExcludesBetween") @system unittest { import
(package) std
std
.
(module) std.conv

A one-stop shop for converting values from one type to another.

Category Functions
Generic asOriginalType castFrom parse to toChars bitCast
Strings text wtext dtext writeText writeWText writeDText hexString
Numeric octal roundTo signed unsigned
Exceptions ConvException ConvOverflowException

Source

std/conv.d

@copyrightCopyright The D Language Foundation 2007-.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Shin Fujishiro, Adam D. Ruppe, Kenji Hara
conv
:
(alias template) text = std.conv.text(T...)(T args) if (T.length > 0)

Convenience functions for converting one or more arguments of any type into _text (the three character widths).

text
;
import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
// Per-iteration bracketing must exclude the untimed `between` from the // window. The same writes count when they run as `timed` but not as // `between`. Compare the two so process-wide noise from concurrent test // threads (getrusage/proc are per-process) drops out of the DIFFERENCE // only on average — the two count() passes run sequentially, so the // signal (32 writes/iter) is sized to dwarf any realistic burst of // cross-thread write syscalls rather than merely exceed it. import
(package) sparkles
sparkles
.
(package) sparkles.test_runner
test_runner
.
(module) sparkles.test_runner.skip

First-class test skipping: skipTest("reason") aborts the current test and the runner records it as SKIPPED — a yellow result line with the reason and an N skipped summary segment — instead of the early-return pattern that silently counts a degraded environment as a pass.

Runtime-only: not usable in @ctfe bodies (the probe compile evaluates them, and a skip there is a compile error) nor in the extracted --better-c/--wasm programs (no druntime classes there). Inside a @benchmark body, prefer skipping at registration time (the top of the body) — a skipTest inside a deferred benchIter/benchCase closure skips only that case's row.

skip
:
(alias) skipTest = noreturn sparkles.test_runner.skip.skipTest(string reason) pure nothrow @nogc @safe

Aborts the current test, recording it as skipped with reason — for environment capabilities a test needs but this machine/run lacks (perf counters, a root-only tracefs, a missing toolchain binary). Callable from the strictest test bodies: throwing an Error is nothrow-legal, and the recycled instance keeps it @nogc (the minimal @trusted covers only the deliberately-@system recycledErrorInstance).

skipTest
;
auto
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
=
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
.
sparkles.test_runner.tier0.Tier0Group sparkles.test_runner.tier0.Tier0Group.tryOpen(bool enabled) @safe

Enables collection when enabled and calibrates the snapshot self-cost; otherwise an unavailable group (mirrors PerfGroup.tryOpen(false)), so the same call sites work.

tryOpen
(true);
if (!
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
.
bool sparkles.test_runner.tier0.Tier0Group.available() const pure nothrow @nogc @safe

Whether Tier-0 counters will be collected (Linux and requested).

available
)
noreturn sparkles.test_runner.skip.skipTest(string reason) pure nothrow @nogc @safe

Aborts the current test, recording it as skipped with reason — for environment capabilities a test needs but this machine/run lacks (perf counters, a root-only tracefs, a missing toolchain binary). Callable from the strictest test bodies: throwing an Error is nothrow-legal, and the recycled instance keeps it @nogc (the minimal @trusted covers only the deliberately-@system recycledErrorInstance).

skipTest
("tier-0 counters unavailable");
static void
void sparkles.test_runner.tier0.__unittest_L434_C5.nop() pure nothrow @nogc @safe
nop
() {}
static void
void sparkles.test_runner.tier0.__unittest_L434_C5.writeBurst() nothrow @nogc @safe
writeBurst
()
{ import
(package) core
core
.
(package) core.sys
sys
.
(package) core.sys.posix
posix
.
(module) core.sys.posix.unistd

D header file for POSIX.

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseBoost License 1.0.@authorsSean Kelly@standardsThe Open Group Base Specifications Issue 8, IEEE Std 1003.1, 2024 Edition
unistd
:
(alias) write = long core.sys.posix.unistd.write(int, scope const(void*), ulong) nothrow @nogc
write
;
char[1]
(local variable) char[1] c
c
= ['x'];
foreach (
(local variable) int _
_
; 0 .. 32) // 0-length writes: syscalls, no output
() @trusted {
long core.sys.posix.unistd.write(int, scope const(void*), ulong) nothrow @nogc
write
(2,
(local variable) char[1] c
c
.
(constant) char* char[1].ptr = &c
ptr
, 0); }();
} const
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inTimed
inTimed
=
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
.
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.count!(void function() nothrow @nogc @safe, void function() pure nothrow @nogc @safe)(scope void function() nothrow @nogc @safe timed, scope void function() pure nothrow @nogc @safe between, uint iters, uint batch = 1u) nothrow @nogc @safe

The counting pass: brackets each timed`()` call with its own pair of snapshots so between() runs outside the counted window, sums the per-call deltas, and averages once. Returns per-iteration deltas; an unavailable source reads nan (it propagates through the sum). batch brackets that many iterations per snapshot pair, so the two /proc reads amortize instead of dominating a fast body (the tier-0 analogue of the perf bracket's ioctl cost). Only sound when between is a no-op — the batched rows — so per-call rows keep ``batch == 1, where this is the original per-iteration loop.

count
(&
void sparkles.test_runner.tier0.__unittest_L434_C5.writeBurst() nothrow @nogc @safe
writeBurst
, &
void sparkles.test_runner.tier0.__unittest_L434_C5.nop() pure nothrow @nogc @safe
nop
, 64); // writes inside the window
const
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inBetween
inBetween
=
(local variable) sparkles.test_runner.tier0.Tier0Group g
g
.
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.count!(void function() pure nothrow @nogc @safe, void function() nothrow @nogc @safe)(scope void function() pure nothrow @nogc @safe timed, scope void function() nothrow @nogc @safe between, uint iters, uint batch = 1u) nothrow @nogc @safe

The counting pass: brackets each timed`()` call with its own pair of snapshots so between() runs outside the counted window, sums the per-call deltas, and averages once. Returns per-iteration deltas; an unavailable source reads nan (it propagates through the sum). batch brackets that many iterations per snapshot pair, so the two /proc reads amortize instead of dominating a fast body (the tier-0 analogue of the perf bracket's ioctl cost). Only sound when between is a no-op — the batched rows — so per-call rows keep ``batch == 1, where this is the original per-iteration loop.

count
(&
void sparkles.test_runner.tier0.__unittest_L434_C5.nop() pure nothrow @nogc @safe
nop
, &
void sparkles.test_runner.tier0.__unittest_L434_C5.writeBurst() nothrow @nogc @safe
writeBurst
, 64); // writes outside the window
if (!
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inTimed
inTimed
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
.
bool std.math.traits.isNaN!(const(double))(const(double) x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
&& !
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inBetween
inBetween
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
.
bool std.math.traits.isNaN!(const(double))(const(double) x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
)
assert(
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inTimed
inTimed
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
-
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inBetween
inBetween
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
> 16,
string std.conv.text!(string, const(double), string, const(double))(string __param_0, const(double) __param_1, string __param_2, const(double) __param_3) pure @safe

Convenience functions for converting one or more arguments of any type into text (the three character widths).

text
("writes in timed must count but in between must not; timed=",
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inTimed
inTimed
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
, " between=",
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) inBetween
inBetween
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscw

write syscalls per iteration

syscw
));
} @("tier0.Tier0Group.selfCostSubtracted") @system unittest { import
(package) std
std
.
(module) std.conv

A one-stop shop for converting values from one type to another.

Category Functions
Generic asOriginalType castFrom parse to toChars bitCast
Strings text wtext dtext writeText writeWText writeDText hexString
Numeric octal roundTo signed unsigned
Exceptions ConvException ConvOverflowException

Source

std/conv.d

@copyrightCopyright The D Language Foundation 2007-.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Shin Fujishiro, Adam D. Ruppe, Kenji Hara
conv
:
(alias template) text = std.conv.text(T...)(T args) if (T.length > 0)

Convenience functions for converting one or more arguments of any type into _text (the three character widths).

text
;
import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
// tryOpen calibrates the per-bracket snapshot cost; count reports net // of it. Assert the calibration CONSTANT directly (same-module access // to the private field): each empty bracket's own /proc read costs // ~1 syscr, so a calibration that measured nothing is broken. The // old form compared two sequentially-run count() passes, whose // process-wide cross-thread read noise differs between the passes — // under a loud parallel suite the comparison flaked. auto
(local variable) sparkles.test_runner.tier0.Tier0Group calibrated
calibrated
=
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
.
sparkles.test_runner.tier0.Tier0Group sparkles.test_runner.tier0.Tier0Group.tryOpen(bool enabled) @safe

Enables collection when enabled and calibrates the snapshot self-cost; otherwise an unavailable group (mirrors PerfGroup.tryOpen(false)), so the same call sites work.

tryOpen
(true);
import
(package) sparkles
sparkles
.
(package) sparkles.test_runner
test_runner
.
(module) sparkles.test_runner.skip

First-class test skipping: skipTest("reason") aborts the current test and the runner records it as SKIPPED — a yellow result line with the reason and an N skipped summary segment — instead of the early-return pattern that silently counts a degraded environment as a pass.

Runtime-only: not usable in @ctfe bodies (the probe compile evaluates them, and a skip there is a compile error) nor in the extracted --better-c/--wasm programs (no druntime classes there). Inside a @benchmark body, prefer skipping at registration time (the top of the body) — a skipTest inside a deferred benchIter/benchCase closure skips only that case's row.

skip
:
(alias) skipTest = noreturn sparkles.test_runner.skip.skipTest(string reason) pure nothrow @nogc @safe

Aborts the current test, recording it as skipped with reason — for environment capabilities a test needs but this machine/run lacks (perf counters, a root-only tracefs, a missing toolchain binary). Callable from the strictest test bodies: throwing an Error is nothrow-legal, and the recycled instance keeps it @nogc (the minimal @trusted covers only the deliberately-@system recycledErrorInstance).

skipTest
;
if (!
(local variable) sparkles.test_runner.tier0.Tier0Group calibrated
calibrated
.
bool sparkles.test_runner.tier0.Tier0Group.available() const pure nothrow @nogc @safe

Whether Tier-0 counters will be collected (Linux and requested).

available
)
noreturn sparkles.test_runner.skip.skipTest(string reason) pure nothrow @nogc @safe

Aborts the current test, recording it as skipped with reason — for environment capabilities a test needs but this machine/run lacks (perf counters, a root-only tracefs, a missing toolchain binary). Callable from the strictest test bodies: throwing an Error is nothrow-legal, and the recycled instance keeps it @nogc (the minimal @trusted covers only the deliberately-@system recycledErrorInstance).

skipTest
("tier-0 counters unavailable");
static void
void sparkles.test_runner.tier0.__unittest_L471_C5.nop() pure nothrow @nogc @safe
nop
() {}
const
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) net
net
=
(local variable) sparkles.test_runner.tier0.Tier0Group calibrated
calibrated
.
sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.count!(void function() pure nothrow @nogc @safe, void function() pure nothrow @nogc @safe)(scope void function() pure nothrow @nogc @safe timed, scope void function() pure nothrow @nogc @safe between, uint iters, uint batch = 1u) nothrow @nogc @safe

The counting pass: brackets each timed`()` call with its own pair of snapshots so between() runs outside the counted window, sums the per-call deltas, and averages once. Returns per-iteration deltas; an unavailable source reads nan (it propagates through the sum). batch brackets that many iterations per snapshot pair, so the two /proc reads amortize instead of dominating a fast body (the tier-0 analogue of the perf bracket's ioctl cost). Only sound when between is a no-op — the batched rows — so per-call rows keep ``batch == 1, where this is the original per-iteration loop.

count
(&
void sparkles.test_runner.tier0.__unittest_L471_C5.nop() pure nothrow @nogc @safe
nop
, &
void sparkles.test_runner.tier0.__unittest_L471_C5.nop() pure nothrow @nogc @safe
nop
, 64);
if (
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) net
net
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
.
bool std.math.traits.isNaN!(const(double))(const(double) x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
)
noreturn sparkles.test_runner.skip.skipTest(string reason) pure nothrow @nogc @safe

Aborts the current test, recording it as skipped with reason — for environment capabilities a test needs but this machine/run lacks (perf counters, a root-only tracefs, a missing toolchain binary). Callable from the strictest test bodies: throwing an Error is nothrow-legal, and the recycled instance keeps it @nogc (the minimal @trusted covers only the deliberately-@system recycledErrorInstance).

skipTest
("/proc/self/io unavailable (no per-task I/O accounting)");
assert(
(local variable) sparkles.test_runner.tier0.Tier0Group calibrated
calibrated
.
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
> 0.5,
string std.conv.text!(string, double)(string __param_0, double __param_1) pure @safe

Convenience functions for converting one or more arguments of any type into text (the three character widths).

text
("calibration must measure the bracket's own read; selfCost.syscr=",
(local variable) sparkles.test_runner.tier0.Tier0Group calibrated
calibrated
.
(field) sparkles.test_runner.tier0.Tier0Stats sparkles.test_runner.tier0.Tier0Group.selfCost

per-bracket snapshot cost; 0 = uncalibrated

selfCost
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
));
// And the subtraction engages: netOfCost clamps at 0 and returns non-negative. assert(!
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) net
net
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
.
bool std.math.traits.isNaN!(const(double))(const(double) x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
&&
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) net
net
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
>= 0,
string std.conv.text!(string, const(double), string)(string __param_0, const(double) __param_1, string __param_2) pure @safe

Convenience functions for converting one or more arguments of any type into text (the three character widths).

text
("net (",
(local variable) const(sparkles.test_runner.tier0.Tier0Stats) net
net
.
(field) double sparkles.test_runner.tier0.Tier0Stats.syscr

read syscalls per iteration (/proc/self/io)

syscr
, ") must be non-negative"));
} } else version (OSX) { import core.stdc.config : c_long; import core.sys.posix.sys.resource : rusage, RUSAGE_SELF; import core.sys.posix.sys.time : timeval; import sparkles.test_runner.perf : readRusageInfo, rusage_info_v4; /// druntime's Darwin `rusage` hides the BSD tail as `ru_opaque[14]`, /// but the kernel always fills it — this is the full `__DARWIN_C_FULL` /// layout from the SDK's `sys/resource.h`, bound to the same symbol. private struct darwinRusage { timeval ru_utime; timeval ru_stime; c_long ru_maxrss; c_long ru_ixrss; c_long ru_idrss; c_long ru_isrss; c_long ru_minflt; c_long ru_majflt; c_long ru_nswap; c_long ru_inblock; c_long ru_oublock; c_long ru_msgsnd; c_long ru_msgrcv; c_long ru_nsignals; c_long ru_nvcsw; c_long ru_nivcsw; } static assert(darwinRusage.sizeof == rusage.sizeof, "the named tail must overlay druntime's ru_opaque[14] exactly"); pragma(mangle, "getrusage") private extern (C) int darwinGetrusage(int who, darwinRusage* usage) @nogc nothrow; /// The Tier-0 counter group (macOS): `getrusage`'s fault/context-switch /// counters plus `proc_pid_rusage`'s lifetime disk-I/O byte counters. /// The `/proc/self/io` syscall/character fields have no macOS analog — /// they stay `-1` in every reading and `deltaStats`' per-field guard /// renders them nan, never fabricated zeros. No calibration: neither /// source carries a per-bracket read cost worth netting (the same /// reasoning the linux body applies to its fault counters). struct Tier0Group { private bool enabled; private static immutable CapabilityAbsence[1] notRequestedAbsence = [ CapabilityAbsence(Capability.counting, "not requested"), ]; /// Whether Tier-0 counters will be collected (requested). bool available() const @safe pure nothrow @nogc => enabled; /// Human-readable availability, for a report header. string status() const @safe pure nothrow => enabled ? "getrusage + proc_pid_rusage disk I/O" : "unavailable (not requested)"; /// What this backend can deliver: scalar counting. CapabilityReport capabilities() const @safe nothrow { if (enabled) return CapabilityReport(Capability.counting, null); return CapabilityReport(Capability.none, notRequestedAbsence[]); } /// Opens the group unless disabled — nothing can fail here. static Tier0Group tryOpen(bool enabled) @safe pure nothrow @nogc => Tier0Group(enabled); /// Releases nothing — the group holds no descriptors. void close() @safe pure nothrow @nogc { } /// Captures one instant's cumulative counters. Tier0Reading snapshot() const @safe nothrow @nogc { Tier0Reading r; r.syscr = r.syscw = r.rdChars = r.wrChars = -1; // no macOS analog darwinRusage ru; if ((() @trusted => darwinGetrusage(RUSAGE_SELF, &ru))() == 0) { r.minflt = ru.ru_minflt; r.majflt = ru.ru_majflt; // XNU reports but never maintains ru_nvcsw (probed live on // Darwin 25.3: 0 → 0 across 32 explicit sleeps, while // minflt/majflt/nivcsw all tick) — a permanently-dead field // must be absent, not a confident 0.00 column. r.volCs = -1; r.involCs = ru.ru_nivcsw; r.rusageOk = true; } rusage_info_v4 info; if (readRusageInfo(info)) { r.rdBytes = info.ri_diskio_bytesread; r.wrBytes = info.ri_diskio_byteswritten; r.ioOk = true; } else r.rdBytes = r.wrBytes = -1; return r; } /// The counting pass: snapshot pairs bracketing `batch` iterations /// each, per-iteration averages (nan propagates through the sum for /// absent fields). /// /// `batch` amortizes the bracket's own two snapshots, which would /// otherwise dominate a fast body — the same reason the perf tier /// batches its ioctl pair (SPEC §6.1). Reordering `between()` after /// its batch is only sound when it is a no-op, so per-call rows keep /// `batch == 1`, which is exactly the original per-iteration loop. Tier0Stats count(Timed, Between)(scope Timed timed, scope Between between, uint iters, uint batch = 1) in (iters > 0) { Tier0Stats sum; const k = batch == 0 ? 1 : batch; uint done; while (done < iters) { const n = k < iters - done ? k : iters - done; done += n; const start = snapshot(); foreach (_; 0 .. n) timed(); const end = snapshot(); foreach (_; 0 .. n) between(); // Raw (divisor 1): `sum` accumulates the whole pass, which the // 1/iters below averages — correct for any batch size. const one = deltaStats(start, end, 1); sum.minflt += one.minflt; sum.majflt += one.majflt; sum.volCs += one.volCs; sum.involCs += one.involCs; sum.syscr += one.syscr; sum.syscw += one.syscw; sum.rdChars += one.rdChars; sum.wrChars += one.wrChars; sum.rdBytes += one.rdBytes; sum.wrBytes += one.wrBytes; } const inv = 1.0 / iters; sum.iters = iters; sum.minflt *= inv; sum.majflt *= inv; sum.volCs *= inv; sum.involCs *= inv; sum.syscr *= inv; sum.syscw *= inv; sum.rdChars *= inv; sum.wrChars *= inv; sum.rdBytes *= inv; sum.wrBytes *= inv; return sum; } /// The tier-0 deltas across one window, as window totals. Tier0Stats windowStats(in Tier0Reading a, in Tier0Reading b) const @safe pure nothrow @nogc => deltaStats(a, b, 1); } @("tier0.Tier0Group.darwinSnapshotMonotonic") @system unittest { auto g = Tier0Group.tryOpen(true); assert(g.available); const a = g.snapshot(); assert(a.rusageOk, "getrusage works on macOS"); assert(a.syscr == -1, "no /proc/self/io analog — guarded, not zero"); assert(a.volCs == -1, "XNU never maintains ru_nvcsw — dead, not zero"); // Fault in fresh pages so the maintained fields provably MOVE — a // reported-but-dead counter must never masquerade as a live one. auto pages = new ubyte[](4 << 20); pages[] = 0xab; const b = g.snapshot(); import std.math : isNaN; const s = g.windowStats(a, b); assert(s.syscr.isNaN && s.rdChars.isNaN && s.volCs.isNaN, "absent/dead fields are nan, never fabricated zeros"); assert(!s.minflt.isNaN, "the rusage fields are real"); assert(s.minflt > 0, "4 MiB of faulted pages moves minflt"); assert(pages[0] == 0xab); if (a.ioOk) assert(b.rdBytes >= a.rdBytes, "disk-I/O bytes are monotonic"); } } else { /// Non-Linux, non-macOS stub: Tier-0 counters are permanently /// unavailable. struct Tier0Group { private static immutable CapabilityAbsence[1] stubAbsence = [ CapabilityAbsence(Capability.counting, "not Linux"), ]; bool available() const @safe pure nothrow @nogc => false; string status() const @safe pure nothrow => "unavailable (not Linux)"; CapabilityReport capabilities() const @safe pure nothrow @nogc => CapabilityReport(Capability.none, stubAbsence[]); static Tier0Group tryOpen(bool) @safe pure nothrow @nogc => Tier0Group(); void close() @safe pure nothrow @nogc {} Tier0Stats count(Timed, Between)(scope Timed, scope Between, uint, uint = 1) { assert(false, "Tier-0 counters are Linux-only"); } Tier0Reading snapshot() @safe pure nothrow @nogc => Tier0Reading(); Tier0Stats windowStats(in Tier0Reading, in Tier0Reading) const @safe pure nothrow @nogc => assert(false, "Tier-0 counters are Linux-only"); } } /// A counter net of its calibrated per-bracket cost, clamped at zero; /// `nan` (source unavailable) passes through untouched. Platform-neutral: /// the darwin perf body (proc_pid_rusage fixed counters) nets its bracket /// cost through the same helper. package double
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(double
(parameter) double total
total
, double
(parameter) double cost
cost
) @safe pure nothrow @nogc
{ import
(package) std
std
.
(package) std.algorithm
algorithm
.
(module) std.algorithm.comparison

This is a submodule of std.algorithm. It contains generic comparison algorithms.

Function Name Description
among Checks if a value is among a set of values, e.g. if (v.among(1, 2, 3)) // v is 1, 2 or 3
castSwitch (new A()).castSwitch((A a)=>1,(B b)=>2) returns 1.
clamp clamp(1, 3, 6) returns 3. clamp(4, 3, 6) returns 4.
cmp cmp("abc", "abcd") is -1, cmp("abc", "aba") is 1, and cmp("abc", "abc") is 0.
either Return first parameter p that passes an if (p) test, e.g. either(0, 42, 43) returns 42.
equal Compares ranges for element-by-element equality, e.g. equal([1, 2, 3], [1.0, 2.0, 3.0]) returns true.
isPermutation isPermutation([1, 2], [2, 1]) returns true.
isSameLength isSameLength([1, 2, 3], [4, 5, 6]) returns true.
levenshteinDistance levenshteinDistance("kitten", "sitting") returns 3 by using the Levenshtein distance algorithm.
levenshteinDistanceAndPath levenshteinDistanceAndPath("kitten", "sitting") returns tuple(3, "snnnsni") by using the Levenshtein distance algorithm.
max max(3, 4, 2) returns 4.
min min(3, 4, 2) returns 2.
mismatch mismatch("oh hi", "ohayo") returns tuple(" hi", "ayo").
predSwitch 2.predSwitch(1, "one", 2, "two", 3, "three") returns "two".

Source

std/algorithm/comparison.d

@copyrightAndrei Alexandrescu 2008-.@licenseBoost License 1.0.@authorsAndrei Alexandrescu
comparison
:
(alias template) max = std.algorithm.comparison.max(T...)(T args) if (T.length >= 2 && !is(CommonType!T == void))

Iterates the passed arguments and returns the maximum value.

Params: args = The values to select the maximum from. At least two arguments must be passed, and they must be comparable with <.

Returns: The maximum of the passed-in values. The type of the returned value is the type among the passed arguments that is able to store the largest value. If at least one of the arguments is NaN, the result is an unspecified value. See $(REF maxElement, std,algorithm,searching) for examples on how to cope with NaNs.

See_Also: $(REF maxElement, std,algorithm,searching)

max
;
import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
return
(parameter) double total
total
.
bool std.math.traits.isNaN!double(double x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
?
(parameter) double total
total
:
double std.algorithm.comparison.max!(double, double)(double a, double b) pure nothrow @nogc @safe

Iterates the passed arguments and returns the maximum value.

Examples

int a = 5;
short b = 6;
double c = 2;
auto d = max(a, b);
assert(is(typeof(d) == int));
assert(d == 6);
auto e = min(a, b, c);
assert(is(typeof(e) == double));
assert(e == 2);
@paramargs The values to select the maximum from. At least two arguments must be passed, and they must be comparable with <.@returnsThe maximum of the passed-in values. The type of the returned value is the type among the passed arguments that is able to store the largest value. If at least one of the arguments is NaN, the result is an unspecified value. See maxElement for examples on how to cope with NaNs.@seemaxElement
max
(0.0,
(parameter) double total
total
-
(parameter) double cost
cost
);
} @("tier0.netOfCost") @safe pure nothrow @nogc unittest { import
(package) std
std
.
(module) std.math

Contains the elementary mathematical functions (powers, roots, and trigonometric functions), and low-level floating-point operations. Mathematical special functions are available in std.mathspecial.

Category Members
Constants E PI PI_2 PI4 M1_PI M2_PI M2_SQRTPI LN10 LN2 LOG2 LOG2E LOG2T LOG10E SQRT2 SQRT1_2
Algebraic abs fabs sqrt cbrt hypot poly nextPow2 truncPow2
Trigonometry sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh
Rounding ceil floor round lround trunc rint lrint nearbyint rndtol quantize
Exponentiation & Logarithms pow powmod exp exp2 expm1 ldexp frexp log log2 log10 logb ilogb log1p scalbn
Remainder fmod modf remainder remquo
Floating-point operations approxEqual feqrel fdim fmax fmin fma isClose nextDown nextUp nextafter NaN getNaNPayload cmp
Introspection isFinite isIdentical isInfinity isNaN isNormal isSubnormal signbit sgn copysign isPowerOf2
Hardware Control IeeeFlags ieeeFlags resetIeeeFlags FloatingPointControl

The functionality closely follows the IEEE754-2008 standard for floating-point arithmetic, including the use of camelCase names rather than C99-style lower case names. All of these functions behave correctly when presented with an infinity or NaN.

The following IEEE 'real' formats are currently supported:

  • 64 bit Big-endian 'double' (eg PowerPC)

  • 128 bit Big-endian 'quadruple' (eg SPARC)

  • 64 bit Little-endian 'double' (eg x86-SSE2)

  • 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)

  • 128 bit Little-endian 'quadruple' (not implemented on any known processor!)

  • Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support

Unlike C, there is no global 'errno' variable. Consequently, almost all of these functions are pure nothrow.

Source

std/math/package.d

@copyrightCopyright The D Language Foundation 2000 - 2011. D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, log2, floor, ceil and lrint functions are based on the CEPHES math library, which is Copyright (C) 2001 Stephen L. Moshier <steve@moshier.net> and are incorporated herein by permission of the author. The author reserves the right to distribute this material elsewhere under different copying permissions. These modifications are distributed here under the following terms:@licenseBoost License 1.0.@authorsWalter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
math
:
(alias template) isNaN = std.math.traits.isNaN(X)(X x) if (isFloatingPoint!X)

Determines if $(D_PARAM x) is NaN. Params: x = a floating point number. Returns: `true` if $(D_PARAM x) is Nan.

isNaN
;
assert(
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(3.0, 1.0) == 2.0);
assert(
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(0.5, 1.0) == 0.0, "clamped: never negative");
assert(
double sparkles.test_runner.tier0.netOfCost(double total, double cost) pure nothrow @nogc @safe

A counter net of its calibrated per-bracket cost, clamped at zero; nan (source unavailable) passes through untouched. Platform-neutral: the darwin perf body (proc_pid_rusage fixed counters) nets its bracket cost through the same helper.

netOfCost
(double.
(constant) double double.nan = nan
nan
, 1.0).
bool std.math.traits.isNaN!double(double x) pure nothrow @nogc @trusted

Determines if x is NaN.

Examples

assert( isNaN(float.init));
assert( isNaN(-double.init));
assert( isNaN(real.nan));
assert( isNaN(-real.nan));
assert(!isNaN(cast(float) 53.6));
assert(!isNaN(cast(real)-53.6));
@paramx a floating point number.@returnstrue if x is Nan.
isNaN
, "unavailable stays unavailable");
} // Whichever body the platform built (real or stub) satisfies the backend // contract, including the optional snapshot/delta primitive. static assert(
(template instance) sparkles.test_runner.capability.isCounterBackend!(sparkles.test_runner.tier0.Tier0Group)
isCounterBackend
!
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
);
static assert(
(template instance) sparkles.test_runner.capability.hasSnapshot!(sparkles.test_runner.tier0.Tier0Group)
hasSnapshot
!
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
);
static assert(!
(template instance) sparkles.test_runner.capability.hasNamedColumns!(sparkles.test_runner.tier0.Tier0Group)
hasNamedColumns
!
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
);
@("tier0.Tier0Group.capabilities") @safe unittest { // Linux and macOS both have real bodies with the same contract; every // other platform is the permanently-unavailable stub. bool
(local variable) bool realBody
realBody
;
version (
linux
linux
)
(local variable) bool realBody
realBody
= true;
version (
OSX
OSX
)
realBody = true; auto
(local variable) sparkles.test_runner.tier0.Tier0Group off
off
=
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
.
sparkles.test_runner.tier0.Tier0Group sparkles.test_runner.tier0.Tier0Group.tryOpen(bool enabled) @safe

Enables collection when enabled and calibrates the snapshot self-cost; otherwise an unavailable group (mirrors PerfGroup.tryOpen(false)), so the same call sites work.

tryOpen
(false);
assert(!
(local variable) sparkles.test_runner.tier0.Tier0Group off
off
.
sparkles.test_runner.capability.CapabilityReport sparkles.test_runner.tier0.Tier0Group.capabilities() const pure nothrow @nogc @safe

What this backend can deliver: process-scope resource counting — present whenever requested (Linux needs no privilege for it).

capabilities
.
bool sparkles.test_runner.capability.has(in sparkles.test_runner.capability.CapabilityReport r, sparkles.test_runner.capability.Capability flag) pure nothrow @nogc @safe

Whether flag is advertised present.

has
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.counting = 1u

concern 1: scalar counting

counting
));
if (
(local variable) bool realBody
realBody
)
{ assert(
(local variable) sparkles.test_runner.tier0.Tier0Group off
off
.
sparkles.test_runner.capability.CapabilityReport sparkles.test_runner.tier0.Tier0Group.capabilities() const pure nothrow @nogc @safe

What this backend can deliver: process-scope resource counting — present whenever requested (Linux needs no privilege for it).

capabilities
.
string sparkles.test_runner.capability.reasonFor(in sparkles.test_runner.capability.CapabilityReport r, sparkles.test_runner.capability.Capability flag) pure nothrow @nogc @safe

The reason flag is absent; null when present or outside the report's domain. (Returning the second-level slice out of an in report is legal under dip1000 — scope is non-transitive; a helper returning the first-level absences slice itself would not compile.)

reasonFor
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.counting = 1u

concern 1: scalar counting

counting
) == "not requested");
auto
(local variable) sparkles.test_runner.tier0.Tier0Group on
on
=
(struct) sparkles.test_runner.tier0.Tier0Group

The Tier-0 counter group. No fds; count snapshots the cumulative counters around each iteration. Carries the calibrated per-bracket self-cost of the snapshots themselves (see calibrateSelfCost).

Tier0Group
.
sparkles.test_runner.tier0.Tier0Group sparkles.test_runner.tier0.Tier0Group.tryOpen(bool enabled) @safe

Enables collection when enabled and calibrates the snapshot self-cost; otherwise an unavailable group (mirrors PerfGroup.tryOpen(false)), so the same call sites work.

tryOpen
(true);
scope (exit)
(local variable) sparkles.test_runner.tier0.Tier0Group on
on
.
void sparkles.test_runner.tier0.Tier0Group.close() pure nothrow @nogc @safe

Nothing to release; present for surface parity with PerfGroup.

close
();
assert(
(local variable) sparkles.test_runner.tier0.Tier0Group on
on
.
sparkles.test_runner.capability.CapabilityReport sparkles.test_runner.tier0.Tier0Group.capabilities() const pure nothrow @nogc @safe

What this backend can deliver: process-scope resource counting — present whenever requested (Linux needs no privilege for it).

capabilities
.
bool sparkles.test_runner.capability.has(in sparkles.test_runner.capability.CapabilityReport r, sparkles.test_runner.capability.Capability flag) pure nothrow @nogc @safe

Whether flag is advertised present.

has
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.counting = 1u

concern 1: scalar counting

counting
));
assert(
(local variable) sparkles.test_runner.tier0.Tier0Group on
on
.
sparkles.test_runner.capability.CapabilityReport sparkles.test_runner.tier0.Tier0Group.capabilities() const pure nothrow @nogc @safe

What this backend can deliver: process-scope resource counting — present whenever requested (Linux needs no privilege for it).

capabilities
.
string sparkles.test_runner.capability.reasonFor(in sparkles.test_runner.capability.CapabilityReport r, sparkles.test_runner.capability.Capability flag) pure nothrow @nogc @safe

The reason flag is absent; null when present or outside the report's domain. (Returning the second-level slice out of an in report is legal under dip1000 — scope is non-transitive; a helper returning the first-level absences slice itself would not compile.)

reasonFor
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.counting = 1u

concern 1: scalar counting

counting
) is null);
} else assert(
(local variable) sparkles.test_runner.tier0.Tier0Group off
off
.
sparkles.test_runner.capability.CapabilityReport sparkles.test_runner.tier0.Tier0Group.capabilities() const pure nothrow @nogc @safe

What this backend can deliver: process-scope resource counting — present whenever requested (Linux needs no privilege for it).

capabilities
.
string sparkles.test_runner.capability.reasonFor(in sparkles.test_runner.capability.CapabilityReport r, sparkles.test_runner.capability.Capability flag) pure nothrow @nogc @safe

The reason flag is absent; null when present or outside the report's domain. (Returning the second-level slice out of an in report is legal under dip1000 — scope is non-transitive; a helper returning the first-level absences slice itself would not compile.)

reasonFor
(
(enum) sparkles.test_runner.capability.Capability

One flag per survey concern (plus real-world sub-splits). Advertised per backend instance after its open handshake.

Capability
.
(enum value) sparkles.test_runner.capability.Capability.counting = 1u

concern 1: scalar counting

counting
) == "not Linux");
}