]>
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/detail/lightweight_main.hpp>
25 namespace fs
= boost::filesystem
;
26 using namespace boost::timer
;
35 boost::int64_t max_cycles
;
37 template< class STD_STRING
>
38 nanosecond_type
time_ctor(const STD_STRING
& s
)
40 boost::timer::auto_cpu_timer tmr
;
41 boost::int64_t count
= 0;
46 } while (count
< max_cycles
);
48 boost::timer::cpu_times elapsed
= tmr
.elapsed();
49 return elapsed
.user
+ elapsed
.system
;
52 nanosecond_type
time_loop()
54 boost::timer::auto_cpu_timer tmr
;
55 boost::int64_t count
= 0;
59 } while (count
< max_cycles
);
61 boost::timer::cpu_times elapsed
= tmr
.elapsed();
62 return elapsed
.user
+ elapsed
.system
;
64 } // unnamed namespace
66 //--------------------------------------------------------------------------------------//
68 //--------------------------------------------------------------------------------------//
70 int cpp_main(int argc
, char* argv
[])
74 cout
<< "Usage: path_times <cycles-in-millions>\n";
78 max_cycles
= std::atoi(argv
[1]) * 1000000LL;
79 cout
<< "testing " << std::atoi(argv
[1]) << " million cycles" << endl
;
81 cout
<< "time_loop" << endl
;
82 nanosecond_type x
= time_loop();
84 cout
<< "time_ctor with string" << endl
;
85 nanosecond_type s
= time_ctor(std::string("/foo/bar/baz"));
87 cout
<< "time_ctor with wstring" << endl
;
88 nanosecond_type w
= time_ctor(std::wstring(L
"/foo/bar/baz"));
91 cout
<< "narrow/wide CPU-time ratio = " << long double(s
) / w
<< endl
;
93 cout
<< "wide/narrow CPU-time ratio = " << long double(w
) / s
<< endl
;
95 cout
<< "returning from main()" << endl
;