]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/performance/thread/overhead_detach.cpp
2 // Copyright Oliver Kowalke 2009.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
13 #include <boost/cstdint.hpp>
14 #include <boost/preprocessor.hpp>
15 #include <boost/program_options.hpp>
17 #include "../clock.hpp"
20 #define JOBS BOOST_PP_LIMIT_REPEAT
23 #define DETACH(z, n, _) \
25 std::thread t( worker); \
26 time_point_type start( clock_type::now() ); \
28 duration_type total = clock_type::now() - start; \
35 duration_type
measure( duration_type overhead
)
37 std::thread( worker
).join();
39 duration_type result
= duration_type::zero();
41 BOOST_PP_REPEAT_FROM_TO(1, JOBS
, DETACH
, _
)
43 result
/= JOBS
; // loops
48 int main( int argc
, char * argv
[])
52 duration_type overhead
= overhead_clock();
53 boost::uint64_t res
= measure( overhead
).count();
54 std::cout
<< "average of " << res
<< " nano seconds" << std::endl
;
58 catch ( std::exception
const& e
)
59 { std::cerr
<< "exception: " << e
.what() << std::endl
; }
61 { std::cerr
<< "unhandled exception" << std::endl
; }