benchmark

Benchmarks functions and appends the results to the results parameter. This function is used by printBenchmarks, and the funs parameter has the same requirements as for that function.

Using benchmark directly is recommended for custom processing and printing of benchmark results.

void
benchmark
(
funs...
)
(,
string moduleName = null
)

Examples

BenchmarkResults[] timings;
benchmark!(
	"file write", { std.file.write("/tmp/deleteme", "hello, world!"); },
	"file read",  { std.file.read("/tmp/deleteme"); })
	(timings);
foreach (ref datum; timings)
{
	writefln("%s: %s ns/iteration", datum.benchmarkName,
		datum.perIteration.to!("nsecs", uint));
}

Meta