View source code
Display the source code in std/datetime/stopwatch.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module std.datetime.stopwatch

Module containing some basic benchmarking and timing functionality.

For convenience, this module publicly imports core.time.

Category Functions
Main functionality StopWatch benchmark
Flags AutoStart

Unlike the other modules in std.datetime, this module is not currently publicly imported in std.datetime.package, because the old versions of this functionality which use TickDuration are in std.datetime.package and would conflict with the symbols in this module. After the old symbols have gone through the deprecation cycle and have been fully removed, then this module will be publicly imported in std.datetime.package. The old, deprecated symbols has been removed from the documentation in December 2019 and currently scheduled to be fully removed from Phobos after 2.094.

So, for now, when using std.datetime.stopwatch, if other modules from std.datetime are needed, then either import them individually rather than importing std.datetime, or use selective or static imports to import std.datetime.stopwatch. e.g.

import std.datetime;
import std.datetime.stopwatch : benchmark, StopWatch;

The compiler will then know to use the symbols from std.datetime.stopwatch rather than the deprecated ones from std.datetime.package.

Functions

NameDescription
benchmark(n) Benchmarks code for speed assessment and comparison.

Structs

NameDescription
StopWatch StopWatch is used to measure time just like one would do with a physical stopwatch, including stopping, restarting, and/or resetting it.

Aliases

NameTypeDescription
AutoStart Flag!("autoStart") Used by StopWatch to indicate whether it should start immediately upon construction.

Authors

Jonathan M Davis and Kato Shoichi

License

Boost License 1.0.