libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::cpu_timer::in_order Class Reference

Measure a time interval using derivatives of the CPU instruction RDTSC. More...

#include <hp_timer.hpp>

Public Member Functions

REALLY_FORCE_INLINE in_order (element_type &d) noexcept(true)
 
REALLY_FORCE_INLINE ~in_order () noexcept(true)
 

Static Public Member Functions

static element_type REALLY_FORCE_INLINE get_start () noexcept(true)
 
static element_type REALLY_FORCE_INLINE get_end () noexcept(true)
 
static element_type REALLY_FORCE_INLINE now () noexcept(true)
 

Detailed Description

Measure a time interval using derivatives of the CPU instruction RDTSC.

The design of this code is directly influenced from [1]. Note that instructions are emitted to ensure that the pipeline in the CPU is serialised at the start of the interval and partially serialised at the end, so the interval measurement is fairly accurate. Note that this costs approximately 20 clock cycles.

[1] "How to Benchmark Code Execution Times on IntelĀ® IA-32 and IA-64 Instruction Set Architectures",

Definition at line 139 of file hp_timer.hpp.

Constructor & Destructor Documentation

◆ in_order()

REALLY_FORCE_INLINE jmmcg::cpu_timer::in_order::in_order ( element_type d)
inlineexplicitnoexcept

Note that this serialises the CPU.

Definition at line 158 of file hp_timer.hpp.

◆ ~in_order()

REALLY_FORCE_INLINE jmmcg::cpu_timer::in_order::~in_order ( )
inlinenoexcept

Note that instructions issued before this dtor will complete before the dtor, but those issued after may be scheduled before the dtor, if the super-scalar CPU has sufficient resources.

Definition at line 165 of file hp_timer.hpp.

Member Function Documentation

◆ get_end()

static element_type REALLY_FORCE_INLINE jmmcg::cpu_timer::in_order::get_end ( )
inlinestaticnoexcept

Definition at line 147 of file hp_timer.hpp.

◆ get_start()

static element_type REALLY_FORCE_INLINE jmmcg::cpu_timer::in_order::get_start ( )
inlinestaticnoexcept

Definition at line 141 of file hp_timer.hpp.

◆ now()

static element_type REALLY_FORCE_INLINE jmmcg::cpu_timer::in_order::now ( )
inlinestaticnoexcept

Definition at line 151 of file hp_timer.hpp.


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