zeit_t test_ucontext_zeit( zeit_t ov)
{
    ctx::stack_allocator alloc;

    ::getcontext( & uc);
    uc.uc_stack.ss_sp = 
        static_cast< char * >( alloc.allocate(ctx::default_stacksize() ) )
        - ctx::default_stacksize();
    uc.uc_stack.ss_size = ctx::default_stacksize();
    ::makecontext( & uc, f2, 7);

    // cache warum-up
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_UCONTEXT, ~)

    zeit_t start( zeit() );
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_UCONTEXT, ~)
    zeit_t total( zeit() - start);

    // we have two jumps and two measuremt-overheads
    total -= ov; // overhead of measurement
    total /= BOOST_PP_LIMIT_MAG; // per call
    total /= 2; // 2x jump_to c1->c2 && c2->c1

    return total;
}
예제 #2
0
zeit_t test_function_zeit( zeit_t ov)
{
    boost::function< void() > fn( boost::bind( f3) );
    // cache warum-up
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FUNCTION, ~)

    zeit_t start( zeit() );
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FUNCTION, ~)
    zeit_t total( zeit() - start);

    // we have two jumps and two measuremt-overheads
    total -= ov; // overhead of measurement
    total /= BOOST_PP_LIMIT_MAG; // per call
    total /= 2; // 2x jump_to c1->c2 && c2->c1

    return total;
}
예제 #3
0
zeit_t test_zeit( zeit_t ov, coro::flag_fpu_t preserve_fpu)
{
#  if defined(BOOST_USE_SEGMENTED_STACKS)
    boost::coroutines::coroutine< void >::pull_type c( fn, coro::attributes( preserve_fpu) );
#  else
    coro::simple_stack_allocator< 8 * 1024 * 1024, 64 * 1024, 8 * 1024 > alloc;
    boost::coroutines::coroutine< void >::pull_type c( fn, coro::attributes( preserve_fpu), alloc);
#  endif

    // cache warum-up
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_COROUTINE, ~)

    zeit_t start( zeit() );
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_COROUTINE, ~)
    zeit_t total( zeit() - start);

    // we have two jumps and two measuremt-overheads
    total -= ov; // overhead of measurement
    total /= BOOST_PP_LIMIT_MAG; // per call
    total /= 2; // 2x jump_to c1->c2 && c2->c1

    return total;
}
예제 #4
0
zeit_t test_fcontext_zeit( zeit_t ov)
{
    stack_allocator alloc;
    fc = ctx::make_fcontext(
        alloc.allocate(stack_allocator::default_stacksize()),
        stack_allocator::default_stacksize(),
        f1);

    ctx::jump_fcontext( & fcm, fc, 7, pres_fpu);

    // cache warum-up
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FCONTEXT, ~)

    zeit_t start( zeit() );
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FCONTEXT, ~)
    zeit_t total( zeit() - start);

    // we have two jumps and two measuremt-overheads
    total -= ov; // overhead of measurement
    total /= BOOST_PP_LIMIT_MAG; // per call
    total /= 2; // 2x jump_to c1->c2 && c2->c1

    return total;
}
zeit_t test_fcontext_zeit( zeit_t ov)
{
    ctx::stack_allocator alloc;
    fc.fc_stack.base = alloc.allocate(ctx::default_stacksize());
    fc.fc_stack.limit =
        static_cast< char * >( fc.fc_stack.base) - ctx::default_stacksize();
    ctx::make_fcontext( & fc, f1);

    ctx::jump_fcontext( & fcm, & fc, 7, preserve_fpu);

    // cache warum-up
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FCONTEXT, ~)

    zeit_t start( zeit() );
BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FCONTEXT, ~)
    zeit_t total( zeit() - start);

    // we have two jumps and two measuremt-overheads
    total -= ov; // overhead of measurement
    total /= BOOST_PP_LIMIT_MAG; // per call
    total /= 2; // 2x jump_to c1->c2 && c2->c1

    return total;
}
예제 #6
0
파일: zeit.hpp 프로젝트: LancelotGHX/Simula
 zeit_t operator()()
 {
     zeit_t start( zeit() );
     return zeit() - start;
 }