Skip to content

Bugprone Tick time monitoring #861

Open
@Petzep

Description

@Petzep

Describe the bug
The time measurement of a tick is bug-prone.

auto t1 = steady_clock::now();
new_status = tick();
auto t2 = steady_clock::now();

This way of measuring time can be reordered by the compiler and will result in a time difference of 0.
A good explanation of this issue can be found here:
Enforcing statement order in C++

The article also discusses a fix.

And I've also seen examples where they fix it with an atomic fence (which cost's no extra cylces)
https://stackoverflow.com/questions/22278963/how-to-prevent-timestamp-from-being-reorder-out

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions