Changeset 56 for trunk


Ignore:
Timestamp:
09/28/07 00:01:43 (12 years ago)
Author:
art
Message:

User can specify the timings needed for synchronisation of the rdtscTimeSource Plugin

Location:
trunk/Plugins/rdtscTimeSource
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Plugins/rdtscTimeSource/Plugin.cpp

    r55 r56  
    2323 
    2424//std::vector<Plugin::PlgMethod>                mMethods; 
     25uint32 syncInterval = 0; 
     26uint32 syncTime = 10; 
     27 
    2528 
    2629//--------------------------------------------------------- 
    2730// Initialize the plugin 
    2831//--------------------------------------------------------- 
    29 extern "C" int plgInitialize(Engine* root) 
     32extern "C" int plgInitialize(Engine* root, PropertyList* args) 
    3033{        
    3134        mRoot = root; 
    3235    mOldTimeSource = mRoot->sClock()->getTimeSource(); 
    3336 
    34          
     37    if (args){ 
     38        if (args->exists("sync_interval")) 
     39        { 
     40            Property& prop = (*args)["luastate"]; 
     41            try{ 
     42                syncInterval = prop.get<uint32>(); 
     43                NR_Log(Log::LOG_PLUGIN, "rdtscTimeSource: sync_interval=%d", syncInterval); 
     44            }catch(boost::bad_any_cast& err){ 
     45                NR_Log(Log::LOG_PLUGIN, "rdtscTimeSource: sync_interval is given, but has a bad type"); 
     46            } 
     47        } 
     48        if (args->exists("sync_duration")) 
     49        { 
     50            Property& prop = (*args)["luastate"]; 
     51            try{ 
     52                syncTime = prop.get<uint32>(); 
     53                NR_Log(Log::LOG_PLUGIN, "rdtscTimeSource: sync_duration=%d", syncTime); 
     54            }catch(boost::bad_any_cast& err){ 
     55                NR_Log(Log::LOG_PLUGIN, "rdtscTimeSource: sync_duration is given, but has a bad type"); 
     56            } 
     57        } 
     58    } 
     59     
    3560        // create cpu instance 
    3661        mCpu.reset(new Cpu()); 
     
    4166        // create Time Source 
    4267        mTimeSource.reset( new rdtscTimeSource(mCpu) ); 
    43  
     68    mTimeSource->setSyncDuration(syncTime); 
     69     
    4470    // check whenever CPU does support the thing 
    4571    if (mTimeSource->isSupported()) 
     
    5076 
    5177        // let sync the timesource every 500 ms 
    52         mRoot->sClock()->setSyncInterval(500); 
     78        mRoot->sClock()->setSyncInterval(syncInterval); 
    5379         
    5480            // declare new function to the scripting engine 
  • trunk/Plugins/rdtscTimeSource/TimeSource.cpp

    r55 r56  
    3131        mCpu = cpu; 
    3232    _isSupported = false; 
     33    _syncDuration = 10; 
    3334         
    3435        // check whenever we have got the high performance counter support 
     
    8788        _syncTime = _currentTime; 
    8889        reset(); 
    89         mCpu->calculateSpeed(10); 
     90        mCpu->calculateSpeed(_syncDuration); 
    9091} 
    9192 
  • trunk/Plugins/rdtscTimeSource/TimeSource.h

    r55 r56  
    8181     **/ 
    8282    bool isSupported() { return _isSupported; } 
    83         
     83 
     84    //! Set the duration in ms how long to sync (require to compute the cpu frequency properly) 
     85    void setSyncDuration(uint32 time) { _syncDuration = time; } 
     86     
    8487private: 
    8588 
     
    9295        //! Cpu to get info 
    9396        boost::shared_ptr<Cpu>  mCpu; 
    94                  
     97 
     98    //! Duration in ms how long to sync 
     99    uint32 _syncDuration;       
    95100}; 
    96101 
Note: See TracChangeset for help on using the changeset viewer.