### Tolerance

ITimingTest usually runs in automatic mode. In this mode, samples are taken sequentially until the error for the estimated time declines to some percentage. This percentage is the tolerance. For example, if the tolerance is 0.05, then samples will continue to be taken until the time measurement has an error of plus or minus 5%.

Automatic sampling estimates the mean of a moving window of samples. This window is sample count samples wide. The error of the mean is half of the 95% confidence interval. When this error (expressed as a fraction) declines below the tolerance, then the window is accepted and its mean returned as the estimated time.

It is possible that the time being measured might never stabilize, and that the required tolerance might never be reached. To handle this contingency, an upper limit has been set on the number of samples taken during automatic sampling. If the maximum number of samples windows is taken, and samples still have not converged, a warning is issued and the final window is accepted.

You might not want to use automatic timing for some tests. If automatic timing is disabled, then the number of samples specified by sample count is taken and their median returned as the measured time, regardless of the error. In this case, tolerance is ignored.