]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/chrono/example/io_ex1.cpp
1 // io_ex1.cpp ----------------------------------------------------------//
3 // Copyright 2010 Howard Hinnant
4 // Copyright 2010 Vicente J. Botet Escriba
5 // Copyright (c) Microsoft Corporation 2014
7 // Distributed under the Boost Software License, Version 1.0.
8 // See http://www.boost.org/LICENSE_1_0.txt
11 This code was adapted by Vicente J. Botet Escriba from Hinnant's html documentation.
12 Many thanks to Howard for making his code available under the Boost license.
17 #include <boost/chrono/config.hpp>
18 #include <boost/chrono/chrono_io.hpp>
19 #include <boost/chrono/system_clocks.hpp>
20 #include <boost/chrono/thread_clock.hpp>
21 #include <boost/chrono/process_cpu_clocks.hpp>
26 using namespace boost
;
27 using namespace boost::chrono
;
29 cout
<< "milliseconds(1) = "
30 << milliseconds(1) << '\n';
31 cout
<< "milliseconds(3) + microseconds(10) = "
32 << milliseconds(3) + microseconds(10) << '\n';
34 cout
<< "hours(3) + minutes(10) = "
35 << hours(3) + minutes(10) << '\n';
37 typedef duration
<long long, ratio
<1, 2500000000ULL> > ClockTick
;
38 cout
<< "ClockTick(3) + nanoseconds(10) = "
39 << ClockTick(3) + nanoseconds(10) << '\n';
41 cout
<< "\nSet cout to use short names:\n";
42 #if BOOST_CHRONO_VERSION==2
43 cout
<< duration_fmt(duration_style::symbol
);
45 cout
<< duration_short
;
47 cout
<< "milliseconds(3) + microseconds(10) = "
48 << milliseconds(3) + microseconds(10) << '\n';
50 cout
<< "hours(3) + minutes(10) = "
51 << hours(3) + minutes(10) << '\n';
53 cout
<< "ClockTick(3) + nanoseconds(10) = "
54 << ClockTick(3) + nanoseconds(10) << '\n';
56 cout
<< "\nsystem_clock::now() = " << system_clock::now() << '\n';
57 #if defined _MSC_VER && _MSC_VER == 1700
59 #if BOOST_CHRONO_VERSION==2
60 cout
<< "\nsystem_clock::now() = " << time_fmt(chrono::timezone::local
) << system_clock::now() << '\n';
61 cout
<< "\nsystem_clock::now() = " << time_fmt(chrono::timezone::local
,"%Y/%m/%d") << system_clock::now() << '\n';
65 #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
66 cout
<< "steady_clock::now() = " << steady_clock::now() << '\n';
68 #if BOOST_CHRONO_VERSION==2
69 cout
<< "\nSet cout to use long names:\n" << duration_fmt(duration_style::prefix
)
70 << "high_resolution_clock::now() = " << high_resolution_clock::now() << '\n';
72 cout
<< "\nSet cout to use long names:\n" << duration_long
73 << "high_resolution_clock::now() = " << high_resolution_clock::now() << '\n';
75 #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
76 cout
<< "\nthread_clock::now() = " << thread_clock::now() << '\n';
78 #if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
79 cout
<< "\nprocess_real_cpu_clock::now() = " << process_real_cpu_clock::now() << '\n';
80 #if BOOST_PLAT_WINDOWS_DESKTOP
81 cout
<< "\nprocess_user_cpu_clock::now() = " << process_user_cpu_clock::now() << '\n';
82 cout
<< "\nprocess_system_cpu_clock::now() = " << process_system_cpu_clock::now() << '\n';
83 cout
<< "\nprocess_cpu_clock::now() = " << process_cpu_clock::now() << '\n';