Aliases from std.datetime.
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.
Suspends and resumes the current benchmark, respectively. This is useful if the benchmark needs to set things up before performing the measurement.
Suspends and resumes the current benchmark, respectively. This is useful if the benchmark needs to set things up before performing the measurement.
Benchmarks one or more functions for speed assessment and comparison, and prints results as formatted text. A baseline timing that accounts for benchmarking overheads is kept along with the results and automatically deducted from all timings. A timing indistinguishable from the baseline looping overhead appears with a run time of zero and indicates a function that does too little work to be timed.
Prints benchmark results as described with printBenchmarks. This is useful if benchmark postprocessing is desired before printing.
Performs all benchmarks previously scheduled with scheduleForBenchmarking, application-wide. Usually not called directly, but instead as support for printBenchmarks. User code may be interested in using this function directly for e.g. results formatting.
The examples shown so far feature simple, ad-hoc benchmarks, but std.benchmark allows for superior automation and systematic use aimed at large projects.
Result of one function's benchmark.
See Source File
std/benchmark.d
Synopsis:
module nxt.module_one; import std.benchmark, std.file; void benchmark_fileWrite() { std.file.write("/tmp/deleteme", "hello, world!"); } void benchmark_fileRead() { std.file.read("/tmp/deleteme"); } mixin(scheduleForBenchmarking); void main() { printBenchmarks(); }
The code above prints:
=============================================================================== module_one relative ns/iter iter/s =============================================================================== fileWrite 144.2K 6.9K fileRead 27.1K 36.9K ===============================================================================
Copyright 2011-