mirror of
https://github.com/boostorg/coroutine.git
synced 2026-02-10 11:22:32 +00:00
allocate on stack
This commit is contained in:
@@ -18,12 +18,13 @@
|
||||
#include "cycle.hpp"
|
||||
#include "preallocated_stack_allocator.hpp"
|
||||
|
||||
typedef preallocated_stack_allocator< 64 * 1024 > stack_allocator;
|
||||
typedef preallocated_stack_allocator< 64 * 1024 > stack_allocator;
|
||||
typedef boost::coroutines::coroutine< void, stack_allocator > coroutine;
|
||||
|
||||
boost::coroutines::flag_fpu_t preserve_fpu = boost::coroutines::fpu_not_preserved;
|
||||
boost::uint64_t jobs = 1000;
|
||||
|
||||
void fn( boost::coroutines::coroutine< void >::push_type & c)
|
||||
void fn( coroutine::push_type & c)
|
||||
{ while ( true) c(); }
|
||||
|
||||
duration_type measure_time()
|
||||
@@ -31,13 +32,13 @@ duration_type measure_time()
|
||||
stack_allocator stack_alloc( jobs + 1);
|
||||
|
||||
// cache warum-up
|
||||
boost::coroutines::coroutine< void >::pull_type c( fn,
|
||||
coroutine::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), 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,
|
||||
coroutine::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), preserve_fpu),
|
||||
stack_alloc);
|
||||
}
|
||||
@@ -54,13 +55,13 @@ cycle_type measure_cycles()
|
||||
stack_allocator stack_alloc( jobs + 1);
|
||||
|
||||
// cache warum-up
|
||||
boost::coroutines::coroutine< void >::pull_type c( fn,
|
||||
coroutine::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), 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,
|
||||
coroutine::pull_type c( fn,
|
||||
boost::coroutines::attributes( stack_allocator::default_stacksize(), preserve_fpu),
|
||||
stack_alloc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user