overhead of clock not in performance output
This commit is contained in:
parent
d541e88a4b
commit
baa2a109a1
@ -29,6 +29,10 @@ project boost/fiber/performance/fiber
|
||||
<variant>release
|
||||
;
|
||||
|
||||
exe overhead_switch
|
||||
: overhead_switch.cpp
|
||||
;
|
||||
|
||||
exe overhead_create
|
||||
: overhead_create.cpp
|
||||
;
|
||||
|
@ -48,7 +48,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -48,7 +48,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -50,7 +50,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -48,7 +48,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
56
performance/fiber/overhead_switch.cpp
Normal file
56
performance/fiber/overhead_switch.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2009.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/fiber/all.hpp>
|
||||
#include <boost/preprocessor.hpp>
|
||||
|
||||
#include "../clock.hpp"
|
||||
|
||||
#ifndef JOBS
|
||||
#define JOBS BOOST_PP_LIMIT_REPEAT
|
||||
#endif
|
||||
|
||||
#define CREATE(z, n, _) \
|
||||
boost::fibers::fiber BOOST_PP_CAT(f,n) ( \
|
||||
[&total,&overhead](){ \
|
||||
time_point_type start( clock_type::now() ); \
|
||||
boost::this_fiber::yield(); \
|
||||
duration_type diff = clock_type::now() - start; \
|
||||
diff -= overhead; \
|
||||
total /= JOBS + 2; /* main-fiber and dispatcher-fiber */\
|
||||
total += diff; \
|
||||
});
|
||||
|
||||
#define JOIN(z, n, _) \
|
||||
BOOST_PP_CAT(f,n) .join();
|
||||
|
||||
duration_type measure( duration_type overhead) {
|
||||
duration_type total = duration_type::zero();
|
||||
BOOST_PP_REPEAT_FROM_TO(1, JOBS, CREATE, _)
|
||||
BOOST_PP_REPEAT_FROM_TO(1, JOBS, JOIN, _);
|
||||
total /= JOBS; // loops
|
||||
return total;
|
||||
}
|
||||
|
||||
int main( int argc, char * argv[]) {
|
||||
try {
|
||||
duration_type overhead = overhead_clock();
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
} catch ( std::exception const& e) {
|
||||
std::cerr << "exception: " << e.what() << std::endl;
|
||||
} catch (...) {
|
||||
std::cerr << "unhandled exception" << std::endl;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
@ -50,7 +50,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -138,7 +138,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
|
||||
boost::uint64_t res = measure10( overhead).count();
|
||||
std::cout << "10 jobs: average of " << res << " nano seconds" << std::endl;
|
||||
|
@ -78,7 +78,6 @@ int main( int argc, char * argv[])
|
||||
throw std::runtime_error("qthreads failed to initialize\n");
|
||||
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << JOBS << " jobs: average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -87,7 +87,6 @@ int main( int argc, char * argv[])
|
||||
tbb::task_scheduler_init init( 1);
|
||||
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << JOBS << " jobs: average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -48,7 +48,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -50,7 +50,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -51,7 +51,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -48,7 +48,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -50,7 +50,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
boost::uint64_t res = measure( overhead).count();
|
||||
std::cout << "average of " << res << " nano seconds" << std::endl;
|
||||
|
||||
|
@ -138,7 +138,6 @@ int main( int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
duration_type overhead = overhead_clock();
|
||||
std::cout << "overhead " << overhead.count() << " nano seconds" << std::endl;
|
||||
|
||||
boost::uint64_t res = measure10( overhead).count();
|
||||
std::cout << "10 jobs: average of " << res << " nano seconds" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user