Mozilla's getting a new look. What do you think?

Interval Timing

NSPR defines a platform-dependent type, PRIntervalTime, for timing intervals of fewer than approximately 6 hours. This chapter describes PRIntervalTime and the functions that allow you to use it for timing purposes:

Interval Time Type and Constants

All timed functions in NSPR require a parameter that depicts the amount of time allowed to elapse before the operation is declared failed. The type of such arguments is PRIntervalTime. Such parameters are common in NSPR functions such as those used for I/O operations and operations on condition variables.

NSPR 2.0 provides interval times that are efficient in terms of performance and storage requirements. Conceptually, they are based on free-running counters that increment at a fixed rate without possibility of outside influence (as might be observed if one was using a time-of-day clock that gets reset due to some administrative action). The counters have no fixed epoch and have a finite period. To make use of these counters, the application must declare a point in time, the epoch, and an amount of time elapsed since that epoch, the interval. In almost all cases the epoch is defined as the value of the interval timer at the time it was sampled.

Interval Functions

Interval timing functions are divided into three groups:

Getting the Current Interval and Ticks Per Second

Converting Standard Clock Units to Platform-Dependent Intervals

Converting Platform-Dependent Intervals to Standard Clock Units

Document Tags and Contributors

 Contributors to this page: teoli, Sheppy
 Last updated by: teoli,