Skip to main content

clock

Function clock 

Source
pub fn clock() -> f64
Expand description

The clock that LSL timestamps use.

liblsl returns steady_clock::now().time_since_epoch() in seconds (src/common.cpp:20). On Linux that is CLOCK_MONOTONIC, whose origin is the moment the machine booted.

ยงWhy this is not Instant

The origin has to match. Two liblsl processes on one machine read the same clock, and an application can push a timestamp from lsl_local_clock() that a consumer on the same machine reads directly. No post-processing runs by default (include/lsl/common.h:103), so nothing corrects a difference.

A first version of this function measured from the start of the process. Every value was then wrong by the age of the machine. A live test against a real liblsl outlet measured the error at 31,426 seconds.

std::time::Instant uses this same clock and keeps its value private, and /proc/uptime counts a different one: it includes time spent suspended, so it read 66,567 on a machine where CLOCK_MONOTONIC read 31,492. The system call is the only source that agrees.

Each platform reads its own clock. machine_clock gives the note for the platform.