Changeset 56
- Timestamp:
- 09/28/2007 12:01:43 AM (5 years ago)
- Location:
- trunk/Plugins/rdtscTimeSource
- Files:
-
- 3 edited
-
Plugin.cpp (modified) (3 diffs)
-
TimeSource.cpp (modified) (2 diffs)
-
TimeSource.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Plugins/rdtscTimeSource/Plugin.cpp
r55 r56 23 23 24 24 //std::vector<Plugin::PlgMethod> mMethods; 25 uint32 syncInterval = 0; 26 uint32 syncTime = 10; 27 25 28 26 29 //--------------------------------------------------------- 27 30 // Initialize the plugin 28 31 //--------------------------------------------------------- 29 extern "C" int plgInitialize(Engine* root )32 extern "C" int plgInitialize(Engine* root, PropertyList* args) 30 33 { 31 34 mRoot = root; 32 35 mOldTimeSource = mRoot->sClock()->getTimeSource(); 33 36 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 35 60 // create cpu instance 36 61 mCpu.reset(new Cpu()); … … 41 66 // create Time Source 42 67 mTimeSource.reset( new rdtscTimeSource(mCpu) ); 43 68 mTimeSource->setSyncDuration(syncTime); 69 44 70 // check whenever CPU does support the thing 45 71 if (mTimeSource->isSupported()) … … 50 76 51 77 // let sync the timesource every 500 ms 52 mRoot->sClock()->setSyncInterval( 500);78 mRoot->sClock()->setSyncInterval(syncInterval); 53 79 54 80 // declare new function to the scripting engine -
trunk/Plugins/rdtscTimeSource/TimeSource.cpp
r55 r56 31 31 mCpu = cpu; 32 32 _isSupported = false; 33 _syncDuration = 10; 33 34 34 35 // check whenever we have got the high performance counter support … … 87 88 _syncTime = _currentTime; 88 89 reset(); 89 mCpu->calculateSpeed( 10);90 mCpu->calculateSpeed(_syncDuration); 90 91 } 91 92 -
trunk/Plugins/rdtscTimeSource/TimeSource.h
r55 r56 81 81 **/ 82 82 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 84 87 private: 85 88 … … 92 95 //! Cpu to get info 93 96 boost::shared_ptr<Cpu> mCpu; 94 97 98 //! Duration in ms how long to sync 99 uint32 _syncDuration; 95 100 }; 96 101
Note: See TracChangeset
for help on using the changeset viewer.
