From 21c949240307e0d405fb437866405c4149456335 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sat, 4 Aug 2018 22:29:40 -0300 Subject: [PATCH] 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. --- CPP11.md | 6 +++--- README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CPP11.md b/CPP11.md index 431eb57..34c2d59 100644 --- a/CPP11.md +++ b/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 start, end; -start = std::chrono::system_clock::now(); +std::chrono::time_point 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 elapsed_seconds = end-start; diff --git a/README.md b/README.md index f7e5515..85f5760 100644 --- a/README.md +++ b/README.md @@ -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 start, end; -start = std::chrono::system_clock::now(); +std::chrono::time_point 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 elapsed_seconds = end-start;