]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/chrono/doc/stopwatches/reference.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / chrono / doc / stopwatches / reference.qbk
CommitLineData
7c673cae
FG
1[/
2 / Copyright (c) 2009-20010 Vicente J. Botet Escriba
3 /
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)
6 /]
7
8[/=================]
9[/section:reference Reference ]
10[/=================]
11
12
13[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
14[section:stopwatches Stopwatches]
15
16[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
17[section:strict_stopwatch_req `StrictStopwatch` Requirements]
18
19A StrictStopwatch measure the amount of time elapsed from a start point in time.
20
21While __Clock are static and not instantiated, `StrictStopwatch` are instantiated and associated to a given __Clock.
22
23A `S` meets the `StrictStopwatch` requirements if:
24
25* `S::clock` meets the __Clock requirements, and
26* meets the requirements specified in the following table.
27
28In this table `S` denote a StrictStopwatch type. `sc` is an instance of `S` const.
29
30[table StrictStopwatch Requirements
31 [[expression] [return type] [operational semantics]]
32 [[`S::clock`] [A model of __Clock.] [The clock associated to this Stopwatch.]]
33 [[`S::duration`] [`S::clock::duration`] [The __duration type of the `clock`.]]
34 [[`S::time_point`] [`S::clock::time_point`] [The __time_point type of the `clock`.]]
35 [[`S()`] [`S&&`] [Constructd a stopwatch.]]
36 [[`sc.elapsed()`] [`S::duration`] [the elapsed time while the __StrictStopwatch was running.]]
37
38]
39
40
41[/ /////////////////////////////
42
43, `ec` is instance of `system::error_code`
44
45 [[`S(ec)`] [`S&&`] [Constructd a stopwatch.]]
46 [[`sc.elapsed(ec)`] [`S::duration`] [the elapsed time while the __StrictStopwatch was running.]]
47
48////////////////////////////// ]
49
50Models of `StrictStopwatch `:
51
52* __strict_stopwatch
53
54[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
55[section:elapsed `sc.elapsed()`]
56
57__return_type `S::duration`.
58
59__returns the elapsed time.
60
61[endsect]
62
63[/ /////////////////////////////
64[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
65[section:elapsed_ec `sc.elapsed(ec)`]
66
67__return_type `S::duration`.
68
69__returns the elapsed time or `S::duration::zero()` if an error occurred.
70
71__effects When there is an internal error stores the error code in the `ec` parameter`.
72
73[endsect]
74////////////////////////////// ]
75[endsect]
76
77
78[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
79[section:stopwatch_req `Stopwatch` Requirements]
80
81As a __StrictStopwatch, a __Stopwatch measure the amount of time elapsed from a start point in time.
82The main difference is that a __Stopwatch can be started and stopped (and restarted).
83The duration between these two time points is called a lap. It could have in addition the capability to collect these lap samples.
84
85A `S` meets the `Stopwatch` requirements if:
86
87* `S` meets the __StrictStopwatch requirements, and
88* meets the requirements specified in the following table.
89
90In this table `S` denote `Stopwatch` type. `s` is an instance of `S`, `sc` is an instance of `S` const.
91
92[table Stopwatch Requirements
93 [[expression] [return type] [operational semantics]]
94 [[`S::laps_collector `] [ A model of __LapsCollector] [Collects the laps's samples.]]
95 [[`S::scoped_run`] [`__stopwatch_runner<S>`] [RAI which `start`/`stop` the `stopwatch`.]]
96 [[`S::scoped_stop`] [`__stopwatch_stopper<S>`] [RAI which `stop`/`start` the `stopwatch`.]]
97
98 [[`S(dont_start)`] [`S&&`] [Constructd a stopwatch.]]
99 [[`S(coll)`] [`S&&`] [Constructd a stopwatch.]]
100
101 [[`s.start()`] [-] [starts a Stopwatch.]]
102 [[`s.stop()`] [-] [stops a Stopwatch.]]
103 [[`s.stop(ec)`] [-] [stops a Stopwatch.]]
104 [[`s.restart()`] [-] [restarts a Stopwatch.]]
105 [[`s.reset()`] [-] [Resets as if it was constructed again.]]
106
107 [[`sc.is_running()`] [`bool`] [whether the stopwatch is running or not.]]
108 [[`sc.elapsed_current_lap()`] [`S::duration`] [the elapsed time since the last start.]]
109 [[`sc.is_running()`] [bool] [true if the Stopwatch is running.]]
110 [[`sc.lap_collector()`] [`S::laps_collector const&`] [the elapsed time while the Stopwatch was running.]]
111
112]
113
114
115[/ /////////////////////////////
116
117`ec` is instance of `system::error_code`
118
119 [[`S(coll,ec)`] [`S&&`] [Constructd a stopwatch.]]
120 [[`s.start(ec)`] [-] [starts a Stopwatch.]]
121 [[`s.restart(ec)`] [-] [restarts a Stopwatch.]]
122 [[`s.reset(ec)`] [-] [Resets as if it was constructed again.]]
123 [[`sc.elapsed_current_lap(ec)`] [`S::duration`] [the elapsed time since the last start.]]
124
125////////////////////////////// ]
126
127Models of `Stopwatch`:
128
129* __stopwatch
130
131[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
132[section:start `start()`]
133
134__effects Starts running the stopwatch.
135
136__throws Any exception the `S::clock::now()` function can throw.
137
138[endsect]
139[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
140[section:stop `stop()`]
141
142__effects Stops running the stopwatch.
143
144__throws Any exception the __LapsCollector can throw.
145
146[endsect]
147[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
148[section:restart `restart()`]
149
150__effects `stop`/`start` the stopwatch.
151
152__throws Any exception the `S::clock::now` function can throw.
153
154[endsect]
155[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
156[section:is_running `sc.is_running()`]
157
158__return_type `bool`.
159
160__returns Whether the stopwatch is running or not.
161
162__throws Nothing.
163
164[endsect]
165
166[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
167[section:elapsed `get_laps_collector()`]
168
169__return_type `const S::laps_collector&`.
170
171__returns the laps_collector instance.
172
173[endsect]
174
175[/ /////////////////////////////
176[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
177[section:start_ec `start(ec)`]
178
179__effects Starts running the stopwatch.
180When there is an internal error stores the error code in the `ec` parameter if it is different from `throws()`.
181
182__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`.
183
184[endsect]
185[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
186[section:stop_ec `stop(ec)`]
187
188__effects Stops running the stopwatch.
189When there is an internal error stores the error code in the `ec` parameter if it is different from `throws()`.
190
191__throws Any exception the `__LapsCollector::store()` or `S::clock::now()` can throw when `ec` is `throws()`
192
193[endsect]
194[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
195[section:restart_ec `restart(ec)`]
196
197__effects `stop`/`start` the stopwatch.
198
199__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`.
200
201[endsect]
202////////////////////////////// ]
203
204[endsect]
205
206[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
207[section:laps_collector_req `LapsCollector` Requirements]
208
209A LapsCollector is collector of the duration of laps.
210
211A `C` meets the `LapsCollector` requirements if:
212
213* it meets the requirements specified in the following table.
214
215In this table `C` denote `LapsCollector` type, `c` is an instance of `C`.
216
217[table LapsCollector Requirements
218 [[expression] [return type] [operational semantics]]
219 [[`C::duration`] [`duration<>`] [The collected duration type.]]
220 [[`c.store(c)`] [-] [stores a duration.]]
221 [[`c.reset()`] [-] [clears the collector.]]
222]
223
224[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
225[section:suspend `c.store(d)`]
226
227__effects Stores the duration `d` on the collector `c`.
228
229__throws `std::bad_alloc` when no memory is available`
230
231[endsect]
232[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
233[section:resume `clear()`]
234
235__effects Clears the collector.
236
237__throws Nothing.
238
239[endsect]
240
241[endsect]
242
243[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
244[section:suspendable_stopwatch_req `SuspendableStopwatch ` Requirements]
245
246A SuspendableStopwatch is a Stopwatch that in addition can be suspended and resumed.
247
248A `S` meets the `SuspendableStopwatch` requirements if:
249
250* `S` meets the __Stopwatch requirements, and
251* meets the requirements specified in the following table.
252
253In this table `S` denote `SuspendableStopwatch` type, `s` is an instance of `S`.
254
255[table Stopwatch Requirements
256 [[expression] [return type] [operational semantics]]
257 [[`S::scoped_suspend`] [`__stopwatch_suspender<S>`] [RAI which `suspend`/`resume` the `stopwatch`.]]
258 [[`S::scoped_resume`] [`__stopwatch_resumer<S>`] [RAI which `resume`/`suspend` the `stopwatch`.]]
259 [[`s.suspend()`] [-] [suspends a Stopwatch.]]
260 [[`s.resume()`] [-] [resumes a Stopwatch.]]
261 [[`sc.is_suspended()`] [`bool`] [whether the stopwatch is suspended or not.]]
262]
263
264
265[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
266[section:suspend `s.suspend()`]
267
268__effects Suspends the stopwatch.
269
270__throws Any exception the `S::clock::now` function can throw.
271
272[endsect]
273[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
274[section:resume `s.resume()`]
275
276__effects Resumes the stopwatch.
277
278__throws Any exception the `S::clock::now` function can throw.
279
280[endsect]
281[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
282[section:is_suspended `sc.is_suspended()`]
283
284__return_type `bool`.
285
286__returns Whether the stopwatch is suspended or not.
287
288__throws Nothing.
289
290[endsect]
291
292[/ /////////////////////////////
293[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
294[section:suspend_ec `s.suspend(ec)`]
295
296__effects Suspends the stopwatch.
297
298__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`
299
300[endsect]
301[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
302[section:resume_ec `s.resume(ec)`]
303
304__effects Resumes the stopwatch.
305
306__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`
307
308[endsect]
309////////////////////////////// ]
310
311[endsect]
312
313
314[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
315[/==================================================]
316[section:stopwatch_scoped_hpp Header `<boost/chrono/stopwatches/stopwatch_scoped.hpp>`]
317[/==================================================]
318
319 namespace boost {
320 namespace chrono {
321 template<class Stopwatch>
322 class stopwatch_runner;
323
324 template<class Stopwatch>
325 class stopwatch_stopper;
326
327 template<class Stopwatch>
328 class stopwatch_suspender;
329
330 template<class Stopwatch>
331 class stopwatch_resumer;
332 }
333 }
334
335[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
336[section:stopwatch_runner Template Class `stopwatch_runner<>`]
337
338Maintains the stopwatch running during the lifetime.
339
340 template<class Stopwatch>
341 class stopwatch_runner
342 {
343 public:
344 typedef Stopwatch stopwatch;
345 stopwatch_runner() = delete;
346 stopwatch_runner(const stopwatch_runner&) = delete;
347 stopwatch_runner& operator=(const stopwatch_runner&) = delete;
348
349 stopwatch_runner(stopwatch & s);
350 ~stopwatch_runner();
351 };
352
353
354
355[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
356[section:c Constructor `stopwatch_runner(stopwatch &s)`]
357
358__requires `! s.is_running()`.
359
360__effects Stores a reference `s` and as if `s.start()`.
361
362__post_condition `s.is_running()`.
363
364__throws Any exception the `s.start()`can throw.
365
366[endsect]
367[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
368[section:d Destructor `~stopwatch_runner()`]
369
370__effects As if `s.stop()`.
371
372__post_condition `! s.is_running()`.
373
374__throws Nothing.
375
376[endsect]
377
378[/ /////////////////////////////
379 stopwatch_runner(stopwatch & s, system::error_code & ec);
380[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
381[section:c_ec Constructor `stopwatch_runner(stopwatch &s, system::error_code &ec)`]
382
383__requires `! s.is_running()`.
384
385__effects Stores a reference `s` and as if `s.start(ec)`.
386
387__post_condition `s.is_running()`.
388
389__throws Any exception the `s.start(ec)`can throw when `ec` is `throws()`
390
391[endsect]
392////////////////////////////// ]
393
394
395[endsect]
396[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
397[section:stopwatch_stopper Template Class `stopwatch_stopper<>`]
398
399Maintains the stopwatch stopped during the lifetime.
400
401 template<class Stopwatch>
402 class stopwatch_stopper
403 {
404 public:
405 typedef Stopwatch stopwatch;
406 stopwatch_stopper() = delete;
407 stopwatch_stopper(const stopwatch_stopper&) = delete;
408 stopwatch_stopper& operator=(const stopwatch_stopper&) = delete;
409
410 stopwatch_stopper(stopwatch & s);
411 ~stopwatch_stopper();
412 };
413
414[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
415[section:c Constructor `stopwatch_stopper(stopwatch &s)`]
416
417__requires `s.is_running()`.
418
419__effects Stores a reference `s` and as if `s.stop()`.
420
421__post_condition `! s.is_running()`.
422
423__throws Any exception the `s.stop()` can throw.
424
425[endsect]
426[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
427[section:d Destructor `~stopwatch_stopper()`]
428
429__effects As if `s.start()`.
430
431__post_condition `s.is_running()`.
432
433__throws Nothing.
434
435[endsect]
436
437[/ /////////////////////////////
438 stopwatch_stopper(stopwatch & s, system::error_code & ec);
439[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
440[section:c_ec Constructor `stopwatch_stopper(stopwatch &s, system::error_code &ec)`]
441
442__requires `s.is_running()`.
443
444__effects Stores a reference `s` and as if `s.stop(ec)`.
445
446__post_condition `! s.is_running()`.
447
448__throws Any exception the `s.stop(ec)` can throw when `ec` is `throws()`
449
450[endsect]
451////////////////////////////// ]
452
453[endsect]
454[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
455[section:stopwatch_suspender Template Class `stopwatch_suspender<>`]
456
457Maintains the stopwatch supended during the lifetime.
458
459 template<class Stopwatch>
460 class stopwatch_suspender
461 {
462 public:
463 typedef Stopwatch stopwatch;
464 stopwatch_suspender() = delete;
465 stopwatch_suspender(const stopwatch_suspender&) = delete;
466 stopwatch_suspender& operator=(const stopwatch_suspender&) = delete;
467 stopwatch_suspender(stopwatch & s);
468 ~stopwatch_suspender();
469 };
470
471[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
472[section:c Constructor `stopwatch_suspender(stopwatch &s)`]
473
474__requires `s.is_running() && ! s.is_suspended()`.
475
476__effects Stores a reference `s` and as if `s.suspend()`.
477
478__post_condition `s.is_running() && s.is_suspended()`.
479
480__throws Any exception the `s.suspend()` can throw.
481
482[endsect]
483[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
484[section:d Destructor `~stopwatch_suspender()`]
485
486__effects As if `s.resume()`.
487
488__post_condition `s.is_running() && ! s.is_suspended()`.
489
490__throws Nothing.
491
492[endsect]
493
494[/ /////////////////////////////
495 stopwatch_suspender(stopwatch & s, system::error_code & ec);
496[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
497[section:c_ec Constructor `stopwatch_suspender(stopwatch &s, system::error_code &ec)`]
498
499__requires `s.is_running() && ! s.is_suspended()`.
500
501__effects Stores a reference `s` and as if `s.suspend(ec)`.
502
503__post_condition `s.is_running() && s.is_suspended()`.
504
505__throws Any exception the `s.suspend(ec)` can throw.
506
507[endsect]
508////////////////////////////// ]
509
510[endsect]
511[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
512[section:stopwatch_resumer Template Class `stopwatch_resumer<>`]
513
514Maintains the stopwatch resumed during the lifetime.
515
516 template<class Stopwatch>
517 class stopwatch_resumer
518 {
519 public:
520 typedef Stopwatch stopwatch;
521 stopwatch_resumer() = delete;
522 stopwatch_resumer(const stopwatch_resumer&) = delete;
523 stopwatch_resumer& operator=(const stopwatch_resumer&) = delete;
524 stopwatch_resumer(stopwatch & s);
525 ~stopwatch_resumer();
526 };
527
528
529[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
530[section:c Constructor `stopwatch_resumer(stopwatch &s)`]
531
532__requires `s.is_running() && s.is_suspended()`.
533
534__effects Stores a reference `s` and as if `s.resume()`.
535
536__post_condition `s.is_running() && ! s.is_suspended()`.
537
538__throws Any exception the `s.resume()` can throw.
539
540[endsect]
541[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
542[section:d Destructor `~stopwatch_resumer()`]
543
544__effects As if `s.suspend()`.
545
546__post_condition `s.is_running() && s.is_suspended()`.
547
548__throws Nothing.
549
550[endsect]
551
552[/ /////////////////////////////
553 stopwatch_resumer(stopwatch & s, system::error_code & ec);
554[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
555[section:c_ec Constructor `stopwatch_resumer(stopwatch &s, system::error_code &ec)`]
556
557__requires `s.is_running() && s.is_suspended()`.
558
559__effects Stores a reference `s` and as if `s.resume(ec)`.
560
561__post_condition `s.is_running() && ! s.is_suspended()`.
562
563__throws Any exception the `s.resume(ec)` can throw.
564
565[endsect]
566////////////////////////////// ]
567
568[endsect] [/ class ]
569
570[endsect] [/ header ]
571
572[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
573[/==================================================]
574[section:dont_start_hpp Header `<boost/chrono/stopwatches/dont_start.hpp>`]
575[/==================================================]
576
577 namespace boost
578 {
579 namespace chrono
580 {
581 struct dont_start_t;
582 static const dont_start_t dont_start;
583 }
584 }
585
586
587[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
588[section:dont_start_t Class `dont_start_t`]
589
590Type used to don't start a Stopwatch at construction time.
591
592 struct dont_start_t { };
593
594[endsect] [/ class ]
595[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
596[section:dont_start Variable `dont_start`]
597
598Instance used to don't start a Stopwatch at construction time.
599
600 static const dont_start_t dont_start = { };
601
602[endsect] [/ var ]
603[endsect] [/ header ]
604
605
606[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
607[/==================================================]
608[section:strict_stopwatch_hpp Header `<boost/chrono/stopwatches/strict_stopwatch.hpp>`]
609[/==================================================]
610
611 namespace boost {
612 namespace chrono {
613 template <class __Clock=high_resolution_clock>
614 class strict_stopwatch;
615
616 // useful typedefs
617 typedef <see above> system_strict_stopwatch;
618 #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
619 typedef <see above> steady_strict_stopwatch;
620 #endif
621 typedef <see above> high_resolution_strict_stopwatch;
622 }}
623
624[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
625[section:strict_stopwatch Template Class `strict_stopwatch<>`]
626
627Knowing how long a part of a program takes to execute is useful in both test and production environments.
628A __strict_stopwatch` object measures elapsed time. It is recommended to use it with clocks that measure wall clock rather than CPU time since the intended use is performance measurement on systems where total elapsed time is more important than just process or CPU time.
629
630The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
631accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
632
633`strict_stopwatch <>` is a model of a __strict_stopwatch_concept.
634
635 template <class __Clock> class strict_stopwatch {
636 public:
637 typedef Clock clock;
638 typedef typename Clock::duration duration;
639 typedef typename Clock::time_point time_point;
640
641 strict_stopwatch( );
642 ~strict_stopwatch();
643
644 duration elapsed( );
645
646 };
647
648Only the specificities of this class are documented here. See __strict_stopwatch_concept for the common parts.
649
650[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
651[section:c1 Constructor `strict_stopwatch()`]
652
653 strict_stopwatch();
654
655__effects constructs and starts the strict_stopwatch.
656
657__throws Any exception the `Clock::now()`can throw.
658
659[endsect]
660
661[/
662 explicit strict_stopwatch( system::error_code & ec );
663 duration elapsed( system::error_code & ec );
664[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
665[section:c2 Constructor `strict_stopwatch( system::error_code &)`]
666
667 explicit strict_stopwatch( system::error_code & ec = throws() );
668
669__effects constructs and starts the strict_stopwatch.
670
671__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
672
673[endsect]
674]
675[endsect]
676
677[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
678[section:typedefs `strict_stopwatch` useful typedefs]
679
680The following typedef are provided as syntactic sugar.
681
682 typedef strict_stopwatch< boost::chrono::system_clock > system_strict_stopwatch;
683 #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
684 typedef strict_stopwatch< boost::chrono:: steady_clock > steady_strict_stopwatch;
685 #endif
686 typedef strict_stopwatch< boost::chrono:: high_resolution_clock > high_resolution_strict_stopwatch;
687
688[endsect] [/ typedefs]
689[endsect] [/ header ]
690
691
692[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
693[/==================================================]
694[section:stopwatch_hpp Header `<boost/chrono/stopwatches/stopwatch.hpp>`]
695[/==================================================]
696
697 namespace boost {
698 namespace chrono {
699 template<typename __Clock=high_resolution_clock, typename __LapsCollector=no_memory<typename Clock::duration> >
700 class stopwatch;
701
702 // useful typedefs
703 typedef <see above> system_stopwatch;
704 #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
705 typedef <see above> steady_stopwatch;
706 #endif
707 typedef <see above> high_resolution_stopwatch;
708 }}
709
710[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
711[section:stopwatch Template Class `stopwatch<>`]
712
713A __stopwatch is a model of __Stopwatch taking as parameters the __Clock and the __LapsCollector.
714
715The main difference respect to a __strict_stopwatch is that the user can stop it.
716
717Each sequence of start-stop results in a new elapsed duration sample that is provided to the __LapsCollector.
718It is up to the __LapsCollector to do whatever it wants with each sample.
719
720Even if it is preferable to use process or thread wide clocks, the default of the Clock parameter is high_resolution_clock,
721as it is the single one ensured on all platforms.
722
723The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
724accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
725
726`stopwatch <>` is a model of a __Stopwatch.
727
728 template<typename Clock, typename LapsCollector >
729 class stopwatch
730 {
731 public:
732 typedef Clock clock;
733 typedef LapsCollector laps_collector;
734 typedef typename Clock::duration duration;
735 typedef typename Clock::time_point time_point;
736 typedef typename Clock::rep rep;
737 typedef typename Clock::period period;
738 BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady;
739
740 stopwatch();
741 explicit stopwatch(const dont_start_t&) noexcept;
742 explicit stopwatch(laps_collector const& coll);
743 stopwatch(laps_collector const& acc, const dont_start_t&);
744 ~stopwatch();
745
746 void restart();
747 void start();
748 void stop();
749 bool is_running() const;
750
751 /**
752 * Elapsed time getter for the current lap.
753 *
754 * Returns: the elapsed time since the last start if no internal error occur.
755 *
756 */
757 duration elapsed_current_lap() const;
758
759
760 duration elapsed() const;
761 /**
762 * Elapsed time for the last lap.
763 *
764 * Returns: the elapsed time of the last lap.
765 *
766 */
767 duration last() const;
768
769 void reset();
770 laps_collector const& get_laps_collector() const noexcept;
771
772 typedef stopwatch_runner<stopwatch<Clock, LapsCollector> > scoped_run;
773 typedef stopwatch_stopper<stopwatch<Clock, LapsCollector> > scoped_stop;
774
775 };
776
777
778Only the specificities of this class are documented here. See __Stopwatch for the common parts.
779
780[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
781[section:c Constructor `stopwatch()`]
782
783 stopwatch();
784
785__effects constructs and starts the stopwatch.
786
787__post_conditions: `is_running()`.
788
789__throws Any exception the `Clock::now()`can throw.
790
791[endsect]
792[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
793[section:c_ns Constructor `stopwatch( const dont_start_t& )`]
794
795 explicit stopwatch(const dont_start_t&) noexcept;
796
797__effects constructs and not starts the stopwatch.
798
799__post_conditions: `! is_running()`.
800
801__throws Nothing`
802
803[endsect]
804[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
805[section:c_coll Constructor `stopwatch(laps_collector const&)`]
806
807 explicit stopwatch(laps_collector const& coll);
808
809__effects constructs copying the laps collector and starts the stopwatch.
810
811__post_conditions: `is_running()`.
812
813__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw.
814
815[endsect]
816[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
817[section:c_coll_ns Constructor `stopwatch(laps_collector const&, const dont_start_t&)`]
818
819 stopwatch(laps_collector const& acc, const dont_start_t&);
820
821__effects constructs copying the laps collector and don't starts the stopwatch.
822
823__post_conditions: `! is_running()`.
824
825__throws Any exception the __LapsCollector copy can throw`
826
827[endsect]
828
829
830
831
832
833[/
834
835 explicit stopwatch(system::error_code & ec);
836 stopwatch(laps_collector const& acc, system::error_code & ec);
837 void restart(system::error_code & ec);
838 void start(system::error_code & ec);
839 void stop(system::error_code & ec);
840 /**
841 * Elapsed time getter for the current lap.
842 *
843 * Effects: Assign the error code if any internal error occur while retrieving the current time.
844 *
845 * Returns: the elapsed time since the start if no internal error occur.
846 *
847 */
848 duration elapsed_current_lap(system::error_code & ec) const;
849 duration elapsed(system::error_code & ec) const;
850[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
851[section:c_ec Constructor `stopwatch( system::error_code &ec)`]
852
853 explicit stopwatch( system::error_code & ec = throws() );
854
855__effects constructs and starts the stopwatch.
856
857__post_conditions: `ec || is_running()`.
858
859__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
860
861[endsect]
862]
863
864[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
865[section:c_coll_ec Constructor `stopwatch(laps_collector const&, system::error_code &)`]
866
867 explicit stopwatch(laps_collector const& acc, system::error_code & ec);
868
869__effects constructs copying the laps collector and starts the stopwatch. Assign the error code if any internal error occur while retrieving the current time.
870
871__post_conditions: `ec || is_running()`.
872
873__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw when `ec` is `throws()`
874
875[endsect]
876
877]
878
879
880[endsect]
881[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
882[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
883[section:typedefs `stopwatch` useful typedefs]
884
885The following typedef are provided as syntactic sugar.
886
887 typedef stopwatch< boost::chrono::system_clock > system_stopwatch;
888 #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
889 typedef stopwatch< boost::chrono:: steady_clock > steady_stopwatch;
890 #endif
891 typedef stopwatch< boost::chrono:: high_resolution_clock > high_resolution_stopwatch;
892
893[endsect] [/ typedefs]
894[endsect] [/ header ]
895
896
897[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
898[/==================================================]
899[section:suspendable_stopwatch_hpp Header `<boost/chrono/stopwatches/suspendable_stopwatch.hpp>`]
900[/==================================================]
901
902 namespace boost {
903 namespace chrono {
904 template<typename __Clock=high_resolution_clock, typename __LapsCollector=no_memory<typename Clock::duration> >
905 class suspendable_stopwatch;
906
907 // useful typedefs
908 typedef <see above> system_suspendable_stopwatch;
909 #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
910 typedef <see above> steady_suspendable_stopwatch;
911 #endif
912 typedef <see above> high_resolution_suspendable_stopwatch;
913 }}
914
915[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
916[section:suspendable_stopwatch Template Class `suspendable_stopwatch<>`]
917
918A __suspendable_stopwatch is a model of __SuspendableStopwatch taking as parameters the __Clock and the __LapsCollector.
919
920The main difference respect to a __stopwatch is that the user can suspend/resume it.
921
922Each sequence of start-stop results in a new elapsed duration sample that is provided to the __LapsCollector.
923This lap can be suspended/resumed.
924
925Even if it is preferable to use process or thread wide clocks, the default of the Clock parameter is high_resolution_clock,
926as it is the single one ensured on all platforms.
927
928The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
929accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
930
931`suspendable_stopwatch<>` is a model of a __SuspendableStopwatch.
932
933 template<typename Clock, typename LapsCollector >
934 class suspendable_stopwatch
935 {
936 public:
937 typedef Clock clock;
938 typedef LapsCollector laps_collector;
939 typedef typename Clock::duration duration;
940 typedef typename Clock::time_point time_point;
941 typedef typename Clock::rep rep;
942 typedef typename Clock::period period;
943 BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady;
944
945 suspendable_stopwatch();
946 explicit suspendable_stopwatch(const dont_start_t&) noexcept;
947 explicit suspendable_stopwatch(laps_collector const& coll);
948 suspendable_stopwatch(laps_collector const& acc, const dont_start_t&);
949
950 ~suspendable_stopwatch();
951
952 void restart();
953 void start();
954 void stop();
955 void suspend();
956 void resume();
957 void reset();
958
959 bool is_running() const;
960 bool is_elapsed() const;
961 duration elapsed_current_lap() const;
962 duration elapsed() const;
963 duration last() const;
964 laps_collector const& get_laps_collector() const noexcept;
965
966 typedef stopwatch_runner<suspendable_stopwatch<Clock, LapsCollector> > scoped_run;
967 typedef stopwatch_stopper<suspendable_stopwatch<Clock, LapsCollector> > scoped_stop;
968 typedef stopwatch_suspender<suspendable_stopwatch<Clock, LapsCollector> > scoped_suspend;
969 typedef stopwatch_resumer<suspendable_stopwatch<Clock, LapsCollector> > scoped_resume;
970
971 };
972
973
974Only the specificities of this class are documented here. See __Stopwatch for the common parts.
975
976[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
977[section:c Constructor `suspendable_stopwatch()`]
978
979 suspendable_stopwatch();
980
981__effects constructs and starts the stopwatch.
982
983__post_conditions: `is_running() && ! is_suspended()`.
984
985__throws Any exception the `Clock::now()`can throw.
986
987[endsect]
988[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
989[section:c_ns Constructor `suspendable_stopwatch( const dont_start_t& )`]
990
991 explicit suspendable_stopwatch(const dont_start_t&) noexcept;
992
993__effects constructs and not starts the stopwatch.
994
995__post_conditions: `! is_running() && ! is_suspended()`.
996
997__throws Nothing`
998
999[endsect]
1000[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1001[section:c_coll Constructor `suspendable_stopwatch(laps_collector const&)`]
1002
1003 explicit suspendable_stopwatch(laps_collector const& coll);
1004
1005__effects constructs copying the laps collector and starts the stopwatch.
1006
1007__post_conditions: `is_running() && ! is_suspended()`.
1008
1009__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw.
1010
1011[endsect]
1012[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1013[section:c_coll_ns Constructor `suspendable_stopwatch(laps_collector const&, const dont_start_t&)`]
1014
1015 suspendable_stopwatch(laps_collector const& acc, const dont_start_t&);
1016
1017__effects constructs copying the laps collector and don't starts the stopwatch.
1018
1019__post_conditions: `! is_running() && ! is_suspended()`.
1020
1021__throws Any exception the __LapsCollector copy can throw`
1022
1023[endsect]
1024
1025
1026[/
1027
1028 explicit suspendable_stopwatch(system::error_code & ec);
1029 suspendable_stopwatch(laps_collector const& acc, system::error_code & ec);
1030 void restart(system::error_code & ec);
1031 void start(system::error_code & ec);
1032 void stop(system::error_code & ec);
1033 void suspend(system::error_code & ec);
1034 void resume(system::error_code & ec);
1035 void reset(system::error_code & ec);
1036 duration elapsed_current_lap(system::error_code & ec) const;
1037 duration elapsed(system::error_code & ec) const;
1038
1039
1040[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1041[section:c_ec Constructor `suspendable_stopwatch( system::error_code &ec)`]
1042
1043 explicit suspendable_stopwatch( system::error_code & ec = throws() );
1044
1045__effects constructs and starts the stopwatch.
1046
1047__post_conditions: `is_running() && ! is_suspended()`.
1048
1049__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
1050
1051[endsect]
1052[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1053[section:c_coll_ec Constructor `suspendable_stopwatch(laps_collector const&, system::error_code &)`]
1054
1055 explicit suspendable_stopwatch(laps_collector const& acc, system::error_code & ec);
1056
1057__effects constructs copying the laps collector and starts the stopwatch. Assign the error code if any internal error occur while retrieving the current time.
1058
1059__post_conditions: `ec || (is_running() && ! is_suspended())`.
1060
1061__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw when `ec` is `throws()`
1062
1063[endsect]
1064]
1065
1066[endsect]
1067[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1068[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1069[section:typedefs `suspendable_stopwatch` useful typedefs]
1070
1071The following typedef are provided as syntactic sugar.
1072
1073 typedef suspendable_stopwatch< boost::chrono::system_clock > system_suspendable_stopwatch;
1074 #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
1075 typedef suspendable_stopwatch< boost::chrono:: steady_clock > steady_suspendable_stopwatch;
1076 #endif
1077 typedef suspendable_stopwatch< boost::chrono:: high_resolution_clock > high_resolution_suspendable_stopwatch;
1078
1079[endsect] [/ typedefs]
1080[endsect] [/ header ]
1081
1082
1083[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1084[section:collectors Collectors]
1085[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1086[/==================================================]
1087[section:no_memory_hpp Header `<boost/chrono/stopwatches/collectors/no_memory.hpp>`]
1088[/==================================================]
1089
1090 namespace boost
1091 {
1092 namespace chrono
1093 {
1094
1095 template<typename Duration>
1096 struct no_memory;
1097
1098 }
1099 }
1100
1101[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1102[section:no_memory Class `no_memory`]
1103
1104 template<typename Duration>
1105 struct no_memory
1106 {
1107 typedef Duration duration;
1108
1109 duration elapsed() const;
1110 duration last() const;
1111 void store(duration const& );
1112 void reset();
1113
1114 };
1115
1116[endsect]
1117
1118[endsect] [/ header ]
1119[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1120[/==================================================]
1121[section:last_lap_hpp Header `<boost/chrono/stopwatches/collectors/last_lap.hpp>`]
1122[/==================================================]
1123
1124 namespace boost
1125 {
1126 namespace chrono
1127 {
1128
1129 template<typename Duration>
1130 struct last_lap;
1131
1132 }
1133 }
1134
1135[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1136[section:last_lap Class `last_lap`]
1137
1138 template<typename Duration>
1139 struct last_lap
1140 {
1141 typedef Duration duration;
1142 duration elapsed() const;
1143 duration last() const;
1144 void store(duration const& d);
1145 void reset();
1146
1147 };
1148
1149[endsect]
1150
1151[endsect] [/ header ]
1152[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1153[/==================================================]
1154[section:laps_accumulator_set_hpp Header `<boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp>`]
1155[/==================================================]
1156
1157 namespace boost
1158 {
1159 namespace chrono
1160 {
1161
1162 template<
1163 typename Duration,
1164 typename Features = accumulators::features<accumulators::tag::count,
1165 accumulators::tag::sum, accumulators::tag::min,
1166 accumulators::tag::max, accumulators::tag::mean>,
1167 typename Weight = void>
1168 struct laps_accumulator_set;
1169
1170 }
1171 }
1172
1173[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1174[section:laps_accumulator_set Class `laps_accumulator_set`]
1175
1176 template<
1177 typename Duration,
1178 typename Features = accumulators::features<accumulators::tag::count,
1179 accumulators::tag::sum, accumulators::tag::min,
1180 accumulators::tag::max, accumulators::tag::mean>,
1181 typename Weight = void>
1182 struct laps_accumulator_set : last_lap<Duration>
1183 {
1184 typedef Duration duration;
1185 typedef accumulators::accumulator_set<typename duration::rep, Features,
1186 Weight> storage_type;
1187
1188 duration elapsed() const;
1189 void store(duration const& d);
1190 void reset();
1191 storage_type const& accumulator_set() const;
1192
1193
1194 };
1195
1196[endsect]
1197[endsect] [/ header ]
1198[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1199[/==================================================]
1200[section:laps_sequence_container_hpp Header `<boost/chrono/stopwatches/collectors/laps_sequence_container.hpp>`]
1201[/==================================================]
1202
1203 namespace boost
1204 {
1205 namespace chrono
1206 {
1207
1208 template<
1209 typename Duration,
1210 typename SequenceContainer = std::list<Duration>
1211 >
1212 struct laps_sequence_container;
1213
1214 }
1215 }
1216
1217[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1218[section:laps_sequence_container Class `laps_sequence_container`]
1219
1220 template<
1221 typename Duration,
1222 typename SequenceContainer = std::list<Duration>
1223 >
1224 struct laps_sequence_container
1225 {
1226 typedef Duration duration;
1227 typedef SequenceContainer storage_type;
1228 typedef typename SequenceContainer::iterator iterator;
1229 typedef typename SequenceContainer::const_iterator const_iterator;
1230
1231 duration elapsed() const;
1232 duration last() const;
1233 storage_type const& container() const;
1234 void store(duration const& d);
1235 void reset();
1236 };
1237
1238[endsect]
1239[endsect] [/ header ]
1240[endsect] [/ collectors ]
1241[endsect] [/ stopwatches]
1242
1243
1244[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1245[section:stopclocks Stopclocks]
1246
1247[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1248[section:formatter_req `Formatter` Requirements]
1249
1250A Formatter outputs on a given ostream a formatted string combining informations from a __StrictStopwatch, the format and the double precision.
1251
1252A Formatter must meet the requirements in the following Table.
1253
1254In this table `F` denote a Formatter type, `f` is an instance of `F`, `p` is an `int`, `ds` is a `__duration_style`, and `os` is a `F::ostream_type`.
1255
1256[table Formatter Requirements
1257 [[expression] [return type] [operational semantics]]
1258 [[`F::char_type`] [The associated char type.] [-]]
1259 [[`F::string_type`] [The associated string type.] [-]]
1260 [[`F::format_type`] [The associated format type ] [-]]
1261 [[`F::ostream_type`] [The associated output stream type ] [-]]
1262 [[`F::`] [A model of ] [-]]
1263 [[`F()`] [F&&] [Default constructible.]]
1264 [[`F(os)`] [F&&] [Explicit Constructible from an std::basic_ostream.]]
1265 [[`F(os)`] [F&&] [Explicit Constructible from an std::basic_ostream.]]
1266 [[`f.set_precision(p)`] [`-`] [Sets the precision used when displaying a double.]]
1267 [[`f.set_duration_style(ds)`] [`-`] [Sets the duration style used when displaying a duration.]]
1268 [[`f(s)`] [`S::time_point`] [outputs on `os` a formatted string combining informations from the Stopwatch `s`, the format `f` and the double precision `p`.]]
1269]
1270
1271
1272Models of `Formatter`:
1273
1274
1275[endsect] [/section:formatter_req]
1276
1277[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1278[section:stopclock_req `StopClock` Requirements]
1279
1280A Stopclock is a Stopwatch that is able to make reports associated to the collected samples.
1281Stopclocks ensure that a report is done once and only once.
1282
1283A Stopclock must meet the requirements in the following Table.
1284In this table `S` denote a Stopclock type and `s` is an instance of `S`, `fmt` `f` is `const S::char_type *` or `const S::string_type &` or `S::format_type`.
1285
1286[table Stopclock Requirements
1287 [[expression] [return type] [operational semantics]]
1288 [[`S::stopwatch_type`] [A model of __Stopwatch] [-]]
1289 [[`S::formater_type`] [A model of __Formater] [-]]
1290
1291 [[`S(fmt)`] [S&&] [Constructor with specific format.]]
1292 [[`s::report()`] [`-`] [Makes a report of the stopclock samples.]]
1293 [[`s::reported()`] [`bool`] [States if a report has already been done.]]
1294]
1295
1296
1297Models of `Stopclock`:
1298
1299
1300[endsect]
1301
1302[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1303[/==================================================]
1304[section:stopwatch_reporter_hpp Header `<boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp>`]
1305[/==================================================]
1306
1307 namespace boost
1308 {
1309 namespace chrono
1310 {
1311
1312 template<
1313 class CharT,
1314 class Stopwatch,
1315 class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> >
1316 class basic_stopwatch_reporter;
1317
1318 template<
1319 class Stopwatch,
1320 class Formatter = typename basic_stopwatch_reporter_default_formatter<char, Stopwatch>::type>
1321 class stopwatch_reporter;
1322
1323 template<class Stopwatch, class Formatter>
1324 struct basic_stopwatch_reporter_default_formatter<char, stopwatch_reporter<Stopwatch, Formatter> >;
1325
1326 template<
1327 class Stopwatch,
1328 class Formatter = typename basic_stopwatch_reporter_default_formatter<wchar_t, Stopwatch>::type>
1329 class wstopwatch_reporter;
1330
1331 template<class Stopwatch, class Formatter>
1332 struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >;
1333
1334 }
1335 }
1336
1337[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1338[section:basic_stopwatch_reporter Template Class `basic_stopwatch_reporter`]
1339
1340 template<
1341 class CharT,
1342 class Stopwatch,
1343 class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> >
1344 class basic_stopwatch_reporter: public Stopwatch
1345 {
1346 public:
1347 typedef typename Stopwatch::clock clock;
1348 typedef Stopwatch stopwatch_type;
1349 typedef Formatter formatter_type;
1350
1351 basic_stopwatch_reporter(const basic_stopwatch_reporter&) = delete;
1352 basic_stopwatch_reporter& operator=(const basic_stopwatch_reporter&) = delete;
1353
1354 basic_stopwatch_reporter() noexcept;
1355 explicit basic_stopwatch_reporter(system::error_code & ec);
1356 explicit basic_stopwatch_reporter(const dont_start_t& tag) noexcept;
1357 explicit basic_stopwatch_reporter(const typename Formatter::char_type* fmt);
1358 explicit basic_stopwatch_reporter(typename Formatter::string_type const& fmt);
1359 explicit basic_stopwatch_reporter(formatter_type fmt);
1360
1361 ~basic_stopwatch_reporter() noexcept;
1362
1363 bool reported() const;
1364 formatter_type& format();
1365
1366 void report() noexcept;
1367
1368 protected:
1369 formatter_type formatter_;
1370 bool reported_;
1371
1372 };
1373
1374[endsect]
1375[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1376[section:stopwatch_reporter Template Class `stopwatch_reporter`]
1377
1378 template<class Stopwatch, class Formatter>
1379 class stopwatch_reporter: public basic_stopwatch_reporter<char, Stopwatch, Formatter>
1380 {
1381 public:
1382 typedef typename Stopwatch::clock clock;
1383 typedef Stopwatch stopwatch_type;
1384 typedef Formatter formatter_type;
1385
1386 stopwatch_reporter(const stopwatch_reporter&) = delete;
1387 stopwatch_reporter& operator=(const stopwatch_reporter&) = delete;
1388 stopwatch_reporter();
1389 explicit stopwatch_reporter(system::error_code & ec);
1390 explicit stopwatch_reporter(const dont_start_t& tag) noexcept;
1391 explicit stopwatch_reporter(formatter_type const& fmt);
1392 explicit stopwatch_reporter(const typename Formatter::char_type* fmt);
1393 explicit stopwatch_reporter(typename Formatter::string_type const& fmt);
1394
1395 typedef stopwatch_runner<stopwatch_reporter<Stopwatch, Formatter> > scoped_run;
1396 typedef stopwatch_stopper<stopwatch_reporter<Stopwatch, Formatter> > scoped_stop;
1397 typedef stopwatch_suspender<stopwatch_reporter<Stopwatch, Formatter> > scoped_suspend;
1398 typedef stopwatch_resumer<stopwatch_reporter<Stopwatch, Formatter> > scoped_resume;
1399
1400 };
1401
1402[endsect]
1403
1404[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1405[section:stopwatch_reporter_ps Partial Specialization `basic_stopwatch_reporter_default_formatter<char_t, stopwatch_reporter<Stopwatch, Formatter> >`]
1406
1407 template<class Stopwatch, class Formatter>
1408 struct basic_stopwatch_reporter_default_formatter<char_t, stopwatch_reporter<Stopwatch, Formatter> >
1409 {
1410 typedef Formatter type;
1411 };
1412
1413[endsect]
1414
1415[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1416[section:wstopwatch_reporter Template Class `wstopwatch_reporter`]
1417
1418 template<class Stopwatch, class Formatter>
1419 class wstopwatch_reporter: public basic_stopwatch_reporter<wchar_t, Stopwatch, Formatter>
1420 {
1421 public:
1422 typedef typename Stopwatch::clock clock;
1423 typedef Stopwatch stopwatch_type;
1424 typedef Formatter formatter_type;
1425
1426 wstopwatch_reporter(const wstopwatch_reporter&) = delete;
1427 wstopwatch_reporter& operator=(const wstopwatch_reporter&) = delete;
1428 wstopwatch_reporter();
1429 explicit wstopwatch_reporter(system::error_code & ec);
1430 explicit wstopwatch_reporter(const dont_start_t& tag) noexcept;
1431
1432 explicit wstopwatch_reporter(formatter_type const& fmt);
1433 explicit wstopwatch_reporter(const typename Formatter::char_type* fmt);
1434 explicit wstopwatch_reporter(typename Formatter::string_type const& fmt);
1435 typedef stopwatch_runner<wstopwatch_reporter<Stopwatch, Formatter> > scoped_run;
1436 typedef stopwatch_stopper<wstopwatch_reporter<Stopwatch, Formatter> > scoped_stop;
1437 typedef stopwatch_suspender<wstopwatch_reporter<Stopwatch, Formatter> > scoped_suspend;
1438 typedef stopwatch_resumer<wstopwatch_reporter<Stopwatch, Formatter> > scoped_resume;
1439
1440 };
1441
1442
1443[endsect]
1444
1445[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1446[section:wstopwatch_reporter_ps Partial Specialization `basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >`]
1447
1448 template<class Stopwatch, class Formatter>
1449 struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >
1450 {
1451 typedef Formatter type;
1452 };
1453
1454[endsect]
1455
1456
1457[endsect] [/ header ]
1458
1459[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1460[/==================================================]
1461[section:strict_stopclock_hpp Header `<boost/chrono/stopwatches/reporters/strict_stopclock.hpp>`]
1462[/==================================================]
1463
1464
1465 namespace boost
1466 {
1467 namespace chrono
1468 {
1469
1470 template<class CharT, typename Clock, class Formatter>
1471 class basic_strict_stopclock;
1472
1473 template<typename Clock=high_resolution_clock,
1474 class Formatter = typename basic_stopwatch_reporter_default_formatter<char, strict_stopwatch<Clock> >::type>
1475 class strict_stopclock;
1476
1477 template<class Stopwatch, class Formatter>
1478 struct basic_stopwatch_reporter_default_formatter<char, strict_stopclock<Stopwatch, Formatter> >
1479 {
1480 typedef Formatter type;
1481 };
1482
1483 } // namespace chrono
1484 } // namespace boost
1485
1486
1487[section:basic_strict_stopclock Template Class `basic_strict_stopclock<>`]
1488
1489 template<class CharT, typename Clock, class Formatter>
1490 class basic_strict_stopclock: public basic_stopwatch_reporter<CharT, strict_stopwatch<Clock>, Formatter>
1491 {
1492 public:
1493 typedef basic_stopwatch_reporter<CharT, strict_stopwatch<Clock>, Formatter> base_type;
1494 typedef Clock clock;
1495 typedef strict_stopwatch<Clock> stopwatch;
1496 typedef Formatter formatter_type;
1497
1498 basic_strict_stopclock();
1499
1500 #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
1501 explicit basic_strict_stopclock(system::error_code & ec);
1502 #endif
1503
1504 explicit basic_strict_stopclock(formatter_type const& fmt);
1505
1506 explicit basic_strict_stopclock(const typename Formatter::char_type* fmt);
1507 explicit basic_strict_stopclock(typename Formatter::string_type const& fmt);
1508
1509 protected:
1510
1511 basic_strict_stopclock(const basic_strict_stopclock&) = delete;
1512 basic_strict_stopclock& operator=(const basic_strict_stopclock&) = delete;
1513 };
1514
1515[endsect] [/ class ]
1516[section:strict_stopclock Template Class `strict_stopclock<>`]
1517
1518 template<typename Clock, class Formatter>
1519 class strict_stopclock: public basic_strict_stopclock<char, Clock, Formatter>
1520 {
1521 public:
1522 typedef Clock clock;
1523 typedef typename base_type::stopwatch stopwatch;
1524 typedef Formatter formatter_type;
1525
1526 strict_stopclock()
1527 {
1528 }
1529
1530 #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
1531 explicit strict_stopclock(system::error_code & ec);
1532 #endif
1533 explicit strict_stopclock(formatter_type const& fmt);
1534 explicit strict_stopclock(const typename Formatter::char_type* fmt);
1535 explicit strict_stopclock(typename Formatter::string_type const& fmt);
1536
1537 protected:
1538
1539 strict_stopclock(const strict_stopclock&) = delete;
1540 strict_stopclock& operator=(const strict_stopclock&) = delete;
1541 };
1542
1543[endsect] [/ class ]
1544[endsect] [/ header ]
1545[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1546[/==================================================]
1547[section:stopclock_hpp Header `<boost/chrono/stopwatches/reporters/stopclock.hpp>`]
1548[/==================================================]
1549
1550[endsect] [/ header ]
1551[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1552[section:formatters Formatters]
1553[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1554[/==================================================]
1555[section:base_formatter_hpp Header `<boost/chrono/stopwatches/formatters/base_formatter.hpp>`]
1556[/==================================================]
1557
1558[endsect] [/ header ]
1559[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1560[/==================================================]
1561[section:elapsed_formatter_hpp Header `<boost/chrono/stopwatches/formatters/elapsed_formatter.hpp>`]
1562[/==================================================]
1563
1564[endsect] [/ header ]
1565[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
1566[/==================================================]
1567[section:accumulator_set_formatter_hpp Header `<boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp>`]
1568[/==================================================]
1569
1570[endsect] [/ header ]
1571[endsect] [/ formatters ]
1572[endsect] [/section:stopclocks]