mirror of
https://github.com/boostorg/coroutine.git
synced 2026-02-10 11:22:32 +00:00
fix performance tests
This commit is contained in:
@@ -18,28 +18,31 @@
|
||||
#include "cycle.hpp"
|
||||
#include "preallocated_stack_allocator.hpp"
|
||||
|
||||
typedef preallocated_stack_allocator< 64 * 1024 > stack_allocator;
|
||||
typedef boost::coroutines::coroutine< void, stack_allocator > coroutine;
|
||||
typedef preallocated_stack_allocator stack_allocator;
|
||||
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()
|
||||
{
|
||||
stack_allocator stack_alloc( jobs + 1);
|
||||
stack_allocator stack_alloc;
|
||||
|
||||
// cache warum-up
|
||||
coroutine::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu),
|
||||
stack_alloc);
|
||||
{
|
||||
// cache warum-up
|
||||
coro_type::pull_type c( fn,
|
||||
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) {
|
||||
coroutine::pull_type c( fn,
|
||||
coro_type::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu),
|
||||
stack_alloc);
|
||||
}
|
||||
@@ -53,16 +56,19 @@ 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
|
||||
coroutine::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu),
|
||||
stack_alloc);
|
||||
{
|
||||
// cache warum-up
|
||||
coro_type::pull_type c( fn,
|
||||
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) {
|
||||
coroutine::pull_type c( fn,
|
||||
coro_type::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), unwind_stack, preserve_fpu),
|
||||
stack_alloc);
|
||||
}
|
||||
@@ -85,7 +91,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;
|
||||
|
||||
Reference in New Issue
Block a user