Changeset 1027

Show
Ignore:
Timestamp:
04/25/08 07:04:52 (13 years ago)
Author:
ppalmers
Message:

simplify system time source class. should give a performance increase due to less function calls.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libieee1394/CycleTimerHelper.cpp

    r1016 r1027  
    187187#if IEEE1394SERVICE_USE_CYCLETIMER_DLL 
    188188    debugOutput( DEBUG_LEVEL_VERBOSE, "requesting DLL re-init...\n" ); 
    189     m_TimeSource.SleepUsecRelative(1000); // some time to settle 
     189    Util::SystemTimeSource::SleepUsecRelative(1000); // some time to settle 
    190190    m_high_bw_updates = UPDATES_WITH_HIGH_BANDWIDTH; 
    191191    if(!initDLL()) { 
     
    343343        // wait for the next update period 
    344344        #if DEBUG_EXTREME_ENABLE 
    345         ffado_microsecs_t now = m_TimeSource.getCurrentTimeAsUsecs(); 
     345        ffado_microsecs_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    346346        int sleep_time = m_sleep_until - now; 
    347347        debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, "(%p) Sleep until %lld/%f (now: %lld, diff=%d) ...\n", 
    348348                    this, m_sleep_until, m_next_time_usecs, now, sleep_time); 
    349349        #endif 
    350         m_TimeSource.SleepUsecAbsolute(m_sleep_until); 
     350        Util::SystemTimeSource::SleepUsecAbsolute(m_sleep_until); 
    351351        debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE, " (%p) back...\n", this); 
    352352    } 
     
    389389 
    390390    // // simulate a random scheduling delay between (0-10ms) 
    391     // ffado_microsecs_t tmp = m_TimeSource.SleepUsecRandom(10000); 
     391    // ffado_microsecs_t tmp = Util::SystemTimeSource::SleepUsecRandom(10000); 
    392392    // debugOutput( DEBUG_LEVEL_VERBOSE, " (%p) random sleep of %llu usecs...\n", this, tmp); 
    393393 
  • trunk/libffado/src/libieee1394/CycleTimerHelper.h

    r980 r1027  
    116116 
    117117    Ieee1394Service &m_Parent; 
    118     Util::SystemTimeSource m_TimeSource; 
    119118    // parameters 
    120119    uint32_t m_ticks_per_update; 
  • trunk/libffado/src/libieee1394/ieee1394service.cpp

    r1008 r1027  
    5656    , m_pCTRHelper ( new CycleTimerHelper( *this, IEEE1394SERVICE_CYCLETIMER_DLL_UPDATE_INTERVAL_USEC ) ) 
    5757    , m_have_new_ctr_read ( false ) 
    58     , m_pTimeSource ( new Util::SystemTimeSource() ) 
    5958    , m_pWatchdog ( new Util::Watchdog() ) 
    6059{ 
     
    8382                                           prio + IEEE1394SERVICE_CYCLETIMER_HELPER_PRIO_INCREASE ) ) 
    8483    , m_have_new_ctr_read ( false ) 
    85     , m_pTimeSource ( new Util::SystemTimeSource() ) 
    8684    , m_pWatchdog ( new Util::Watchdog() ) 
    8785{ 
     
    116114    } 
    117115 
    118     delete m_pTimeSource; 
    119116    delete m_pWatchdog; 
    120117    if ( m_handle ) { 
     
    391388uint64_t 
    392389Ieee1394Service::getCurrentTimeAsUsecs() { 
    393     if(m_pTimeSource) { 
    394         return m_pTimeSource->getCurrentTimeAsUsecs(); 
    395     } else { 
    396         debugError("No timesource!\n"); 
    397         return 0; 
    398     } 
     390    return Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    399391} 
    400392 
  • trunk/libffado/src/libieee1394/ieee1394service.h

    r940 r1027  
    4444 
    4545namespace Util { 
    46     class TimeSource; 
    4746    class Watchdog; 
    4847} 
     
    331330    bool                    m_have_new_ctr_read; 
    332331 
    333     // the time source 
    334     Util::TimeSource*   m_pTimeSource; 
    335  
    336332    // the RT watchdog 
    337333    Util::Watchdog*     m_pWatchdog; 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r1005 r1027  
    145145 
    146146    #ifdef DEBUG 
    147     uint64_t now = m_manager.get1394Service().getCurrentTimeAsUsecs(); 
     147    uint64_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    148148    int diff = now - m_last_loop_entry; 
    149149    if(diff < 100) { 
  • trunk/libffado/src/libutil/SystemTimeSource.cpp

    r1026 r1027  
    3434 
    3535namespace Util { 
    36  
    37 IMPL_DEBUG_MODULE( SystemTimeSource, SystemTimeSource, DEBUG_LEVEL_NORMAL ); 
    38  
    39 SystemTimeSource::SystemTimeSource() 
    40 { 
    41 } 
    42  
    43 SystemTimeSource::~SystemTimeSource() 
    44 { 
    45 } 
    4636 
    4737void 
  • trunk/libffado/src/libutil/SystemTimeSource.h

    r1015 r1027  
    2626 
    2727#include "../debugmodule/debugmodule.h" 
    28 #include "TimeSource.h" 
     28 
     29typedef uint64_t ffado_microsecs_t; 
    2930 
    3031namespace Util { 
    3132 
    3233class SystemTimeSource 
    33     : public Util::TimeSource 
    3434{ 
     35private: // don't allow objects to be created 
     36    SystemTimeSource() {}; 
     37    virtual ~SystemTimeSource() {}; 
    3538 
    3639public: 
    37  
    38     SystemTimeSource(); 
    39     virtual ~SystemTimeSource(); 
    40  
    41     // implement the TimeSource interface 
    42     ffado_microsecs_t getCurrentTime(); 
    43     ffado_microsecs_t getCurrentTimeAsUsecs(); 
    44     inline ffado_microsecs_t unWrapTime(ffado_microsecs_t t) {return t;}; 
    45     inline ffado_microsecs_t wrapTime(ffado_microsecs_t t) {return t;}; 
     40    static ffado_microsecs_t getCurrentTime(); 
     41    static ffado_microsecs_t getCurrentTimeAsUsecs(); 
    4642 
    4743    static void SleepUsecRelative(ffado_microsecs_t usecs); 
     
    4945     
    5046    /** 
    51      * @brief sleeps for a random amound to usecs 
     47     * @brief sleeps for a random amount of usecs 
    5248     * @param max_usec max usecs 
    5349     * @return number of usecs slept 
    5450     */ 
    5551    static ffado_microsecs_t SleepUsecRandom(ffado_microsecs_t max_usec); 
    56 protected: 
    57     DECLARE_DEBUG_MODULE; 
    58  
    5952}; 
    6053 
  • trunk/libffado/src/libutil/Watchdog.cpp

    r980 r1027  
    7272 
    7373    #ifdef DEBUG 
    74     uint64_t now = SystemTimeSource().getCurrentTimeAsUsecs(); 
     74    uint64_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    7575    int diff = now - m_last_loop_entry; 
    7676    if(diff < 100) { 
     
    121121 
    122122    #ifdef DEBUG 
    123     uint64_t now = SystemTimeSource().getCurrentTimeAsUsecs(); 
     123    uint64_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    124124    int diff = now - m_last_loop_entry; 
    125125    if(diff < 100) { 
  • trunk/libffado/src/SConscript

    r992 r1027  
    8181        libutil/StreamStatistics.cpp \ 
    8282        libutil/SystemTimeSource.cpp \ 
    83         libutil/TimeSource.cpp \ 
    8483        libutil/TimestampedBuffer.cpp \ 
    8584        libutil/Watchdog.cpp \ 
  • trunk/libffado/tests/test-bufferops.cpp

    r864 r1027  
    4242    int i=0; 
    4343     
    44     Util::SystemTimeSource time; 
    4544    ffado_microsecs_t start; 
    4645    ffado_microsecs_t elapsed; 
     
    8483        } 
    8584 
    86         start = time.getCurrentTimeAsUsecs(); 
     85        start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    8786        byteSwapToBus(buffer_1, nb_quadlets); 
    88         elapsed = time.getCurrentTimeAsUsecs() - start; 
     87        elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; 
    8988        printMessage( " took %lluusec...\n", elapsed); 
    9089         
     
    116115    int i=0; 
    117116     
    118     Util::SystemTimeSource time; 
    119117    ffado_microsecs_t start; 
    120118    ffado_microsecs_t elapsed; 
     
    153151        } 
    154152 
    155         start = time.getCurrentTimeAsUsecs(); 
     153        start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    156154        convertFromInt24AndLabelAsMBLA(buffer_1, nb_quadlets); 
    157         elapsed = time.getCurrentTimeAsUsecs() - start; 
     155        elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; 
    158156        printMessage( " took %lluusec...\n", elapsed); 
    159157    } 
     
    186184    int i=0; 
    187185     
    188     Util::SystemTimeSource time; 
    189186    ffado_microsecs_t start; 
    190187    ffado_microsecs_t elapsed; 
     
    236233    } 
    237234 
    238         start = time.getCurrentTimeAsUsecs(); 
     235        start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    239236        convertFromFloatAndLabelAsMBLA(buffer_1, nb_quadlets); 
    240         elapsed = time.getCurrentTimeAsUsecs() - start; 
     237        elapsed = Util::SystemTimeSource::getCurrentTimeAsUsecs() - start; 
    241238        printMessage( " took %lluusec...\n", elapsed); 
    242239    } 
  • trunk/libffado/tests/test-watchdog.cpp

    r939 r1027  
    4343using namespace Util; 
    4444 
    45 SystemTimeSource timesource; 
    4645DECLARE_GLOBAL_DEBUG_MODULE; 
    4746 
     
    5756    bool Execute() { 
    5857        debugOutput(DEBUG_LEVEL_VERBOSE, "execute\n"); 
    59         ffado_microsecs_t start = timesource.getCurrentTimeAsUsecs(); 
     58        ffado_microsecs_t start = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
    6059        ffado_microsecs_t stop_at = start + m_time; 
    6160        int cnt; 
    6261        int dummyvar = 0; 
    63         while(timesource.getCurrentTimeAsUsecs() < stop_at) { 
     62        while(Util::SystemTimeSource::getCurrentTimeAsUsecs() < stop_at) { 
    6463            cnt=1000; 
    6564            while(cnt--) { dummyvar++; } 
     
    6766 
    6867        // ensure that dummyvar doesn't get optimized away 
    69         bool always_true = (dummyvar + timesource.getCurrentTimeAsUsecs() != 0); 
     68        bool always_true = (dummyvar + Util::SystemTimeSource::getCurrentTimeAsUsecs() != 0); 
    7069 
    7170        bool stop = (m_nb_hangs == 0); 
     
    7372 
    7473        // we sleep for 100ms after a 'hang' 
    75         timesource.SleepUsecRelative(1000*100); 
     74        Util::SystemTimeSource::SleepUsecRelative(1000*100); 
    7675 
    7776        // we want the thread to exit after m_nb_hangs 'hangs' 
     
    183182    // start the watchdog 
    184183    w->start(); 
    185     timesource.SleepUsecRelative(1000*1000*1); 
     184    Util::SystemTimeSource::SleepUsecRelative(1000*1000*1); 
    186185 
    187186    // start the first thread, should be harmless since it's hang time is too low 
    188187    thread1->Start(); 
    189     timesource.SleepUsecRelative(1000*1000*1); 
     188    Util::SystemTimeSource::SleepUsecRelative(1000*1000*1); 
    190189 
    191190    // start the second thread, should be rescheduled since it hangs too long 
     
    193192 
    194193    // wait for a while 
    195     timesource.SleepUsecRelative(1000*1000*5); 
     194    Util::SystemTimeSource::SleepUsecRelative(1000*1000*5); 
    196195 
    197196