]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/chrono/example/manipulate_clock_object.cpp
1 // manipulate_clock_object.cpp ----------------------------------------------------------//
3 // Copyright 2008 Howard Hinnant
4 // Copyright 2008 Beman Dawes
5 // Copyright 2009 Vicente J. Botet Escriba
7 // Distributed under the Boost Software License, Version 1.0.
8 // See http://www.boost.org/LICENSE_1_0.txt
11 This code was extracted by Vicente J. Botet Escriba from Beman Dawes time2_demo.cpp which
12 was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
13 Many thanks to Howard for making his code available under the Boost license.
14 The original code was modified to conform to Boost conventions and to section
15 20.9 Time utilities [time] of the C++ committee's working paper N2798.
16 See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
18 time2_demo contained this comment:
20 Much thanks to Andrei Alexandrescu,
29 #include <boost/chrono/chrono.hpp>
30 #include <boost/type_traits.hpp>
34 using namespace boost::chrono
;
38 #pragma warning(disable:4100)
40 void manipulate_clock_object(system_clock clock
)
45 system_clock::duration delay
= milliseconds(5);
46 system_clock::time_point start
= clock
.now();
48 while ((clock
.now() - start
) <= delay
) {}
50 system_clock::time_point stop
= clock
.now();
51 system_clock::duration elapsed
= stop
- start
;
52 std::cout
<< "paused " << nanoseconds(elapsed
).count() << " nanoseconds\n";
58 manipulate_clock_object(system_clock());