Ignore:
Timestamp:
Mar 10, 2014, 6:17:42 PM (10 years ago)
Author:
hock@…
Message:

TEST_F(SystemQueueTimingTest, TimingMultipleCalls)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/SystemQueue-tests.cc

    r12756 r12757  
    289289    SystemQueueTimingTest() :
    290290        SystemQueueTest()  /* super constructor */,
    291         sysq( SystemQueue::instance() )
     291        sysq( SystemQueue::instance() ),
     292        calls(0)
    292293    {
    293294    }
     
    321322       
    322323        // info
    323         cout << "/// Timing difference: " << diff << " microseconds" << endl;
     324        cout << "### Timing difference: " << diff << " microseconds" << endl;
    324325       
    325326        EXPECT_LT( abs(diff), margin );
    326327       
     328        calls++;
    327329        checkmark = true;
    328330    }
    329331
    330332    SystemQueue& sysq;
     333    int calls;
    331334};
    332335
     
    443446}
    444447
     448
     449/**
     450 *  Like TimingSingleCall but tests whether the timings change when multiple events are scheduled.
     451 */
     452TEST_F(SystemQueueTimingTest, TimingMultipleCalls)
     453{
     454    ptime now = microsec_clock::local_time();
     455   
     456    sysq.scheduleCall(
     457        boost::bind(&SystemQueueTimingTest::TimeCheckingCall, this,
     458                    now, DELAY_TIME*1000 * 2, DELAY_MARGIN),
     459        DELAY_TIME * 2
     460    );
     461
     462    sysq.scheduleCall(
     463        boost::bind(&SystemQueueTimingTest::TimeCheckingCall, this,
     464                    now, DELAY_TIME*1000 * 3, DELAY_MARGIN),
     465        DELAY_TIME * 3
     466    );
     467
     468    sysq.scheduleCall(
     469        boost::bind(&SystemQueueTimingTest::TimeCheckingCall, this,
     470                    now, DELAY_TIME*1000, DELAY_MARGIN),
     471        DELAY_TIME
     472    );
     473
     474    // main thread is going to sleep..
     475    usleep(DELAY_TIME * 3000 + DELAY_MARGIN * 2);
     476    wait_for_checkmark(MAX_WAIT);  // XXX wait_until_empty
     477   
     478    // make sure the measurement function was called at all
     479    EXPECT_EQ(3, calls) << "Not every event was performed..";
     480}
Note: See TracChangeset for help on using the changeset viewer.