benchmark

Benchmarks code for speed assessment and comparison.

ulong[]
benchmark
(
fun...
)
(
uint times
,
ulong[] result = null
)

Parameters

fun

aliases of callable objects (e.g. function names). Each should take no arguments.

times uint

The number of times each function is to be executed.

result ulong[]

The optional store for the return value. If null is passed in, new store is allocated appropriately.

Return Value

Type: ulong[]

An array of n uints. Element at slot i contains the number of milliseconds spent in calling the ith function times times.

Examples

int a;
void f0() { }
void f1() { auto b = a; }
void f2() { auto b = to!(string)(a); }
auto r = benchmark!(f0, f1, f2)(10_000_000);
Suggestion Box / Bug Report