Improve std::chrono example (#34)

* Improve std::chrono example

Closes #32 .

@skwllsp arguing makes sense, so the example can be updated to use steady_clock or it could guarantee that the system clock is steady using `std::chrono::system_clock::is_steady`, but I don't think that would simplify things.
This commit is contained in:
Tulio Leao
2018-08-04 22:29:40 -03:00
committed by Anthony Calandra
parent 687c0ce558
commit 21c9492403
2 changed files with 6 additions and 6 deletions

View File

@@ -652,10 +652,10 @@ baz(p1);
### std::chrono
The chrono library contains a set of utility functions and types that deal with _durations_, _clocks_, and _time points_. One use case of this library is benchmarking code:
```c++
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
std::chrono::time_point<std::chrono::steady_clock> start, end;
start = std::chrono::steady_clock::now();
// Some computations...
end = std::chrono::system_clock::now();
end = std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;