Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
LatencyTracker Class Reference

Fixed-capacity rolling window of network round-trip time samples. More...

#include <latency_tracker.h>

Classes

struct  Stats

Public Member Functions

void addSample (qint64 ms)
Stats stats () const
QList< qint64 > recentSamples () const
 Snapshot of the current window in chronological order (oldest first).
void clear ()

Static Public Attributes

static constexpr int WindowSize = 64

Private Attributes

std::array< qint64, WindowSizesamples {}
int head = 0
 index where the next sample will be written
int count = 0
 number of valid samples, capped at WindowSize

Detailed Description

Fixed-capacity rolling window of network round-trip time samples.

The hot path (addSample) is a single array store and is intentionally free of allocations, locks, or signal emissions so that recording one sample per completed command cannot affect gameplay performance. Aggregate statistics are only computed on demand in stats(), which callers should throttle.

Member Function Documentation

◆ addSample()

void LatencyTracker::addSample ( qint64 ms)
Here is the caller graph for this function:

◆ clear()

void LatencyTracker::clear ( )
Here is the caller graph for this function:

◆ recentSamples()

QList< qint64 > LatencyTracker::recentSamples ( ) const

Snapshot of the current window in chronological order (oldest first).

Here is the caller graph for this function:

◆ stats()

LatencyTracker::Stats LatencyTracker::stats ( ) const
Here is the caller graph for this function:

Member Data Documentation

◆ count

int LatencyTracker::count = 0
private

number of valid samples, capped at WindowSize

◆ head

int LatencyTracker::head = 0
private

index where the next sample will be written

◆ samples

std::array<qint64, WindowSize> LatencyTracker::samples {}
private

◆ WindowSize

int LatencyTracker::WindowSize = 64
staticconstexpr

The documentation for this class was generated from the following files: