mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 01:54:36 +03:00
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:
committed by
Anthony Calandra
parent
687c0ce558
commit
21c9492403
6
CPP11.md
6
CPP11.md
@@ -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;
|
||||
|
||||
|
||||
@@ -1201,10 +1201,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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user