MICROS_PER_SECOND
MICROS_PER_SECOND = 1000000
Microseconds in a second.
A span of time and the resolution it is drawn at.
The resolution is derived from the span, never chosen by the caller. A timeline is pannable and zoomable down to the second, so the same code has to draw a ten-second window and a two-year one. Letting the caller pick a bucket size means a zoomed-out view asking for per-second buckets and building sixty million of them, which is a page that never renders. Instead the window picks the finest rung of the ladder that keeps the bucket count under the cap.
Buckets are aligned to the resolution rather than to the window's start, so panning by half a bucket does not shift every boundary and make the same commits appear to move between bars. A reader panning a chart expects the bars to stay put.
Everything is in unix microseconds, because that is the precision a commit is stamped with and rounding to seconds here would collapse two commits from the same flush into one point.
__construct(int $fromMicrotime, int $toMicrotime, int $resolution) : mixed
Constructs a window.
| int | $fromMicrotime | Inclusive start, in unix microseconds. |
| int | $toMicrotime | Inclusive end, in unix microseconds. |
| int | $resolution | Bucket width in seconds. |
When the window ends before it starts, or the resolution is not positive.
spanning(int $fromMicrotime, int $toMicrotime, int $maxBuckets = \self::MAX_BUCKETS) : self
A window over a span, at the finest resolution that fits.
| int | $fromMicrotime | Inclusive start, in unix microseconds. |
| int | $toMicrotime | Inclusive end, in unix microseconds. |
| int | $maxBuckets | Buckets to stay under. |
The window.