From dc9769c1a57f30b984243b568a162eab54a5b66d Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Sun, 26 Jan 2014 20:03:26 +0100 Subject: [PATCH] add progr option for unwinding in operformance tests --- performance/performance_create_prealloc.cpp | 19 +++++++++++-------- performance/performance_create_protected.cpp | 17 ++++++++++++----- performance/performance_create_simple.cpp | 17 ++++++++++++----- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/performance/performance_create_prealloc.cpp b/performance/performance_create_prealloc.cpp index 2e2382f..a82906d 100644 --- a/performance/performance_create_prealloc.cpp +++ b/performance/performance_create_prealloc.cpp @@ -18,9 +18,10 @@ #include "cycle.hpp" #include "preallocated_stack_allocator.hpp" -typedef preallocated_stack_allocator< 64 * 1024 > stack_allocator; +typedef preallocated_stack_allocator stack_allocator; boost::coroutines::flag_fpu_t preserve_fpu = boost::coroutines::fpu_not_preserved; +boost::coroutines::flag_unwind_t unwind_stack = boost::coroutines::stack_unwind; boost::uint64_t jobs = 1000; void fn( boost::coroutines::coroutine< void >::push_type & c) @@ -28,17 +29,17 @@ void fn( boost::coroutines::coroutine< void >::push_type & c) duration_type measure_time() { - stack_allocator stack_alloc( jobs + 1); + stack_allocator stack_alloc; // cache warum-up boost::coroutines::coroutine< void >::pull_type c( fn, - boost::coroutines::attributes( stack_allocator::default_stacksize(), preserve_fpu), + boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu), stack_alloc); time_point_type start( clock_type::now() ); for ( std::size_t i = 0; i < jobs; ++i) { boost::coroutines::coroutine< void >::pull_type c( fn, - boost::coroutines::attributes( stack_allocator::default_stacksize(), preserve_fpu), + boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu), stack_alloc); } duration_type total = clock_type::now() - start; @@ -51,17 +52,17 @@ duration_type measure_time() # ifdef BOOST_CONTEXT_CYCLE cycle_type measure_cycles() { - stack_allocator stack_alloc( jobs + 1); + stack_allocator stack_alloc; // cache warum-up boost::coroutines::coroutine< void >::pull_type c( fn, - boost::coroutines::attributes( stack_allocator::default_stacksize(), preserve_fpu), + boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu), stack_alloc); cycle_type start( cycles() ); for ( std::size_t i = 0; i < jobs; ++i) { boost::coroutines::coroutine< void >::pull_type c( fn, - boost::coroutines::attributes( stack_allocator::default_stacksize(), preserve_fpu), + boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu), stack_alloc); } cycle_type total = cycles() - start; @@ -78,11 +79,12 @@ int main( int argc, char * argv[]) { bind_to_processor( 0); - bool preserve = false; + bool preserve = false, unwind = true; boost::program_options::options_description desc("allowed options"); desc.add_options() ("help", "help message") ("fpu,f", boost::program_options::value< bool >( & preserve), "preserve FPU registers") + ("unwind,u", boost::program_options::value< bool >( & unwind), "unwind coroutine-stack") ("jobs,j", boost::program_options::value< boost::uint64_t >( & jobs), "jobs to run"); boost::program_options::variables_map vm; @@ -100,6 +102,7 @@ int main( int argc, char * argv[]) } if ( preserve) preserve_fpu = boost::coroutines::fpu_preserved; + if ( ! unwind) unwind_stack = boost::coroutines::no_stack_unwind; boost::uint64_t res = measure_time().count(); std::cout << "average of " << res << " nano seconds" << std::endl; diff --git a/performance/performance_create_protected.cpp b/performance/performance_create_protected.cpp index 0d2f862..e48c805 100644 --- a/performance/performance_create_protected.cpp +++ b/performance/performance_create_protected.cpp @@ -20,6 +20,7 @@ typedef boost::coroutines::protected_stack_allocator stack_allocator; boost::coroutines::flag_fpu_t preserve_fpu = boost::coroutines::fpu_not_preserved; +boost::coroutines::flag_unwind_t unwind_stack = boost::coroutines::stack_unwind; boost::uint64_t jobs = 1000; void fn( boost::coroutines::coroutine< void >::push_type & c) @@ -30,11 +31,13 @@ duration_type measure_time() stack_allocator stack_alloc; // cache warum-up - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); time_point_type start( clock_type::now() ); for ( std::size_t i = 0; i < jobs; ++i) { - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); } duration_type total = clock_type::now() - start; total -= overhead_clock(); // overhead of measurement @@ -49,11 +52,13 @@ cycle_type measure_cycles() stack_allocator stack_alloc; // cache warum-up - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); cycle_type start( cycles() ); for ( std::size_t i = 0; i < jobs; ++i) { - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); } cycle_type total = cycles() - start; total -= overhead_cycle(); // overhead of measurement @@ -69,11 +74,12 @@ int main( int argc, char * argv[]) { bind_to_processor( 0); - bool preserve = false; + bool preserve = false, unwind = true; boost::program_options::options_description desc("allowed options"); desc.add_options() ("help", "help message") ("fpu,f", boost::program_options::value< bool >( & preserve), "preserve FPU registers") + ("unwind,u", boost::program_options::value< bool >( & unwind), "unwind coroutine-stack") ("jobs,j", boost::program_options::value< boost::uint64_t >( & jobs), "jobs to run"); boost::program_options::variables_map vm; @@ -91,6 +97,7 @@ int main( int argc, char * argv[]) } if ( preserve) preserve_fpu = boost::coroutines::fpu_preserved; + if ( ! unwind) unwind_stack = boost::coroutines::no_stack_unwind; boost::uint64_t res = measure_time().count(); std::cout << "average of " << res << " nano seconds" << std::endl; diff --git a/performance/performance_create_simple.cpp b/performance/performance_create_simple.cpp index 971a002..a579edb 100644 --- a/performance/performance_create_simple.cpp +++ b/performance/performance_create_simple.cpp @@ -20,6 +20,7 @@ typedef boost::coroutines::simple_stack_allocator stack_allocator; boost::coroutines::flag_fpu_t preserve_fpu = boost::coroutines::fpu_not_preserved; +boost::coroutines::flag_unwind_t unwind_stack = boost::coroutines::stack_unwind; boost::uint64_t jobs = 1000; void fn( boost::coroutines::coroutine< void >::push_type & c) @@ -30,11 +31,13 @@ duration_type measure_time() stack_allocator stack_alloc; // cache warum-up - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); time_point_type start( clock_type::now() ); for ( std::size_t i = 0; i < jobs; ++i) { - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); } duration_type total = clock_type::now() - start; total -= overhead_clock(); // overhead of measurement @@ -49,11 +52,13 @@ cycle_type measure_cycles() stack_allocator stack_alloc; // cache warum-up - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); cycle_type start( cycles() ); for ( std::size_t i = 0; i < jobs; ++i) { - boost::coroutines::coroutine< void >::pull_type c( fn, boost::coroutines::attributes( preserve_fpu), stack_alloc); + boost::coroutines::coroutine< void >::pull_type c( fn, + boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc); } cycle_type total = cycles() - start; total -= overhead_cycle(); // overhead of measurement @@ -69,11 +74,12 @@ int main( int argc, char * argv[]) { bind_to_processor( 0); - bool preserve = false; + bool preserve = false, unwind = true; boost::program_options::options_description desc("allowed options"); desc.add_options() ("help", "help message") ("fpu,f", boost::program_options::value< bool >( & preserve), "preserve FPU registers") + ("unwind,u", boost::program_options::value< bool >( & unwind), "unwind coroutine-stack") ("jobs,j", boost::program_options::value< boost::uint64_t >( & jobs), "jobs to run"); boost::program_options::variables_map vm; @@ -91,6 +97,7 @@ int main( int argc, char * argv[]) } if ( preserve) preserve_fpu = boost::coroutines::fpu_preserved; + if ( ! unwind) unwind_stack = boost::coroutines::no_stack_unwind; boost::uint64_t res = measure_time().count(); std::cout << "average of " << res << " nano seconds" << std::endl;