Devel-StatProfiler

 view release on metacpan or  search on metacpan

src/runloop.cpp  view on Meta::CPAN


double
devel::statprofiler::test_hires_time()
{
    return 1234567890 + counter * (sampling_interval / 1000000.0);
}

#if defined(_WIN32)

static void
win32_nanosleep_busywait(unsigned nsec) {
    LONGLONG current, wanted;

    QueryPerformanceCounter((LARGE_INTEGER *) &wanted);
    wanted += nsec * performance_counter_frequency / 1000000000;

    do {
        QueryPerformanceCounter((LARGE_INTEGER *) &current);
    } while (current < wanted);
}

src/runloop.cpp  view on Meta::CPAN

    // ugly and inefficient, but good enough for testing
    for (;MY_CXT.outer_runloop;) {
        test_counter_increment_mutex.lock();
        if (test_counter_increment < sampling_interval) {
            test_counter_increment_mutex.unlock();
            break;
        }
        test_counter_increment_mutex.unlock();

#if defined(_WIN32)
        win32_nanosleep_busywait(100000);
#else
        timespec sleep = {0, 100000};
        while (nanosleep(&sleep, &sleep) == EINTR)
            ;
#endif
    }

    if (!MY_CXT.outer_runloop) {
        test_counter_increment_mutex.lock();
        counter += test_counter_increment / sampling_interval;

src/runloop.cpp  view on Meta::CPAN

    }
}

static void
test_increment_counter(CounterCxt *cxt)
{
    delete cxt;

    for (;;) {
#if defined(_WIN32)
        win32_nanosleep_busywait(100000);
#else
        timespec sleep = {0, 100000};
        while (nanosleep(&sleep, &sleep) == EINTR)
            ;
#endif

        test_counter_increment_mutex.lock();
        if (test_counter_increment >= sampling_interval) {
            counter += test_counter_increment / sampling_interval;
            test_counter_increment %= sampling_interval;



( run in 0.285 second using v1.01-cache-2.11-cpan-87723dcf8b7 )