]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/filesystem/test/path_times.cpp
1 // Boost Filesystem path_times.cpp ---------------------------------------------------//
3 // Copyright Beman Dawes 2013
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 // Library home page: http://www.boost.org/libs/filesystem
10 #include <boost/config/warning_disable.hpp>
12 #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
13 # define BOOST_FILESYSTEM_NO_DEPRECATED
15 #ifndef BOOST_SYSTEM_NO_DEPRECATED
16 # define BOOST_SYSTEM_NO_DEPRECATED
19 #include <boost/timer/timer.hpp>
20 #include <boost/filesystem/path.hpp>
21 #include <boost/cstdint.hpp>
23 #include <boost/config.hpp>
24 # if defined( BOOST_NO_STD_WSTRING )
25 # error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
28 #include <boost/detail/lightweight_main.hpp>
30 namespace fs
= boost::filesystem
;
31 using namespace boost::timer
;
41 boost::int64_t max_cycles
;
43 template <class STD_STRING
>
44 nanosecond_type
time_ctor(const STD_STRING
& s
)
46 boost::timer::auto_cpu_timer tmr
;
47 boost::int64_t count
= 0;
52 } while (count
< max_cycles
);
54 boost::timer::cpu_times elapsed
= tmr
.elapsed();
55 return elapsed
.user
+ elapsed
.system
;
58 nanosecond_type
time_loop()
60 boost::timer::auto_cpu_timer tmr
;
61 boost::int64_t count
= 0;
65 } while (count
< max_cycles
);
67 boost::timer::cpu_times elapsed
= tmr
.elapsed();
68 return elapsed
.user
+ elapsed
.system
;
70 } // unnamed namespace
72 //--------------------------------------------------------------------------------------//
74 //--------------------------------------------------------------------------------------//
76 int cpp_main(int argc
, char* argv
[])
80 cout
<< "Usage: path_times <cycles-in-millions>\n";
84 max_cycles
= std::atoi(argv
[1]) * 1000000LL;
85 cout
<< "testing " << std::atoi(argv
[1]) << " million cycles" << endl
;
87 cout
<< "time_loop" << endl
;
88 nanosecond_type x
= time_loop();
90 cout
<< "time_ctor with string" << endl
;
91 nanosecond_type s
= time_ctor(std::string("/foo/bar/baz"));
93 cout
<< "time_ctor with wstring" << endl
;
94 nanosecond_type w
= time_ctor(std::wstring(L
"/foo/bar/baz"));
97 cout
<< "narrow/wide CPU-time ratio = " << long double(s
)/w
<< endl
;
99 cout
<< "wide/narrow CPU-time ratio = " << long double(w
)/s
<< endl
;
101 cout
<< "returning from main()" << endl
;