Skip to content

Present C++ timing features #409

Closed
Closed
@sponce

Description

@sponce

Mainly the chrono library, including clocks, time_point and duration so that people can easily do dedicated timing of a few lines of code, basically though code like :

#include <chrono>

// other clocktypes to high_resolution_clock are steady_clock or system_clock
// see https://www.modernescpp.com/index.php/the-three-clocks for details
std::chrono::high_resolution_clock clock;

clock::time_point startTime = clock::now();
... // code to be timed
std::chrono::duration<float> ticks = clock::now() - startTime;
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
std::cout << "it took " << duration.count() << " ticks, that is " << millis.count() << " ms\n";

Metadata

Metadata

Assignees

Labels

AdvancedContent for the "advanced" course

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions