fix performance tests

This commit is contained in:
Oliver Kowalke
2014-01-27 19:52:57 +01:00
parent e74929f66a
commit 98dae1bc98
5 changed files with 67 additions and 99 deletions

View File

@@ -18,13 +18,13 @@
#include "cycle.hpp"
typedef boost::coroutines::protected_stack_allocator stack_allocator;
typedef boost::coroutines::coroutine< void, stack_allocator > coroutine;
typedef boost::coroutines::coroutine< void, stack_allocator > coro_type;
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( coroutine::push_type & c)
void fn( coro_type::push_type & c)
{ while ( true) c(); }
duration_type measure_time()
@@ -32,11 +32,13 @@ duration_type measure_time()
stack_allocator stack_alloc;
// cache warum-up
coroutine::pull_type c( fn, boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc);
coro_type::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) {
coroutine::pull_type c( fn, boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc);
coro_type::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
@@ -51,11 +53,13 @@ cycle_type measure_cycles()
stack_allocator stack_alloc;
// cache warum-up
coroutine::pull_type c( fn, boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc);
coro_type::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) {
coroutine::pull_type c( fn, boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc);
coro_type::pull_type c( fn,
boost::coroutines::attributes( unwind_stack, preserve_fpu), stack_alloc);
}
cycle_type total = cycles() - start;
total -= overhead_cycle(); // overhead of measurement
@@ -76,7 +80,7 @@ int main( int argc, char * argv[])
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 stack")
("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;