liveBook · Manning

Timespec_get

timespec_get is a C standard library function that obtains calendar time for a specified time base and stores it in a struct timespec object.

How 2 Manning books explain it

Modern C

timespec_get is a C standard library function that obtains a calendar time with a struct timespec representation for a specified time base.

How it is used
Obtains finer-grained calendar-time readings and brackets code for performance measurements.
How deep it goes
Gives the function declaration, explains its time base and representation, and examines measurement bias without detailing its implementation.
Examples
Brackets several loops with `timespec_get` calls, then collects elapsed-time statistics from successive readings.
What you can do after
Apply it via the C standard library to obtain time readings and assess their measurement overhead.

Read how Modern C explains timespec_get →

Modern C, Third Edition

timespec_get is a C standard-library function that obtains the current calendar time and stores it in a timespec object.

How it is used
Uses timespec_get for finer-grained calendar time and to bracket code in performance measurements.
How deep it goes
Explains its time base and precision, then examines measurement bias through repeated timing experiments; does not establish a universal clock resolution.
Examples
Shows clock calls around loops and compares per-iteration costs for loops with and without timespec_get.
What you can do after
Practice/perform repeated timings with timespec_get while accounting for the bias introduced by clock calls.

Read how Modern C, Third Edition explains timespec_get →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.