2 / Copyright (c) 2009-20012 Vicente J. Botet Escriba
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
14 [heading Measuring elapsed time]
16 Knowing how long a program, a function or a specific code block takes to execute is useful in both test and production environments.
17 __Boost_Chrono introduces the __strict_stopwatch_concept concept which is a mechanism to measure the elapsed time.
18 __strict_stopwatch`<>` is the basic model of __strict_stopwatch_concept.
20 [heading Reporting elapsed time]
22 It is often necessary to report elapsed time on a user display or in a log file. __stopwatch_reporter provides a runtime reporting mechanism for this purpose which can be invoked in just one line of code.
24 using namespace boost::chrono;
27 __stopwatch_reporter<__stopwatch<__process_cpu_clocks> > _;
31 Will produce the following output
33 real 0.034s, cpu 0.031s (93.0%), user 0.031s, system 0.000s
35 As this is one of the expression more commonly use, the library provides a __stopclock shortcut so the preceding can be written as
39 __stopclock<__process_cpu_clocks> _;