cycle_type measure_cycles_ec() { boost::context::execution_context ctx( boost::context::execution_context::current() ); // cache warum-up boost::context::fixedsize_stack alloc; boost::context::execution_context ectx( std::allocator_arg, alloc, bar); ectx( & ctx); cycle_type start( cycles() ); for ( std::size_t i = 0; i < jobs; ++i) { ectx( & ctx); } cycle_type total = cycles() - start; total -= overhead_cycle(); // overhead of measurement total /= jobs; // loops total /= 2; // 2x jump_fcontext return total; }
duration_type measure_time_ec() { boost::context::execution_context ctx( boost::context::execution_context::current() ); mctx = & ctx; // cache warum-up boost::context::fixedsize_stack alloc; boost::context::execution_context ectx( alloc, bar); ectx(); time_point_type start( clock_type::now() ); for ( std::size_t i = 0; i < jobs; ++i) { ectx(); } duration_type total = clock_type::now() - start; total -= overhead_clock(); // overhead of measurement total /= jobs; // loops total /= 2; // 2x jump_fcontext return total; }