Data<S,IS,N>:: Data(const IS& s, float th, float pf_scale, const BPMatrix::Options& opts) : tree(), seq(s), root(), max_pa(), weight(s.begin()->size()) { BPMatrix bp(s, pf_scale, opts); std::list<Profiler> prof; typename IS::const_iterator x; if (bp.n_matrices()>1) { BPMatrix::matrix_iterator bp_it = bp.matrix_begin(); for (x=s.begin(); x!=s.end(); ++x, ++bp_it) prof.push_back(Profiler(*x, **bp_it, 1.0)); } else { for (x=s.begin(); x!=s.end(); ++x) prof.push_back(Profiler(*x, bp, 1.0)); } DAGBuilder<N> builder(prof, bp, th); builder.build(tree); find_root(root, tree); find_max_parent(max_pa, tree); fill_weight(weight, prof); }
//---------------------------------------------------------------------------------------------------- void GBEmulator::Run() { m_bRunning = true; #ifdef _DEBUG string oPath; ifstream oFile( "debug_load.ini" ); if( oFile ) { while( getline( oFile, oPath ) ) { if( oPath.front() != ';' ) { LoadCartridge( oPath.c_str() ); break; } } oFile.close(); } #endif while( m_bRunning ) { SDL_Event oEvent; while( SDL_PollEvent( &oEvent ) ) { switch( oEvent.type ) { case SDL_KEYDOWN: HandleShortcuts( &oEvent ); // Intentional fall-through case SDL_KEYUP: SimulateInput( &oEvent ); break; case SDL_DROPFILE: LoadCartridge( oEvent.drop.file ); SDL_free( oEvent.drop.file ); break; case SDL_QUIT: m_bRunning = false; break; } } Update(); } Profiler()->DisplayProfiles(); }
// DE: 20090325: Profiler has a list of threads to profile ProfilerThread::ProfilerThread(HANDLE target_process_, const std::vector<HANDLE>& target_threads) : profilers(), target_process(target_process_) { // DE: 20090325: Profiler has a list of threads to profile, one Profiler instance per thread profilers.reserve(target_threads.size()); for(std::vector<HANDLE>::const_iterator it = target_threads.begin(); it != target_threads.end(); ++it){ profilers.push_back(Profiler(target_process_, *it, callstacks, flatcounts)); } numsamplessofar = 0; failed = false; symbolsPercent = 0; numThreadsRunning = (int)target_threads.size(); filename = wxFileName::CreateTempFileName(wxEmptyString); }
//class related ParseTsStream::ParseTsStream() { #if !defined(CROSS_COMPILE) // log4c_init(); #endif pat_packet = new PatParse(); pmt_packet = new PmtParse(); ts_packet_count = 1; mycat = log4c_category_get("tsparser.tsstream"); input_memcopy_timer = Profiler("input_memcpy"); pes_pkt_copy_timer = Profiler("pes_pktcopy"); pes_parse_timer = Profiler("peshdr_parse"); ts_pkt_profiler = Profiler("overall_pkt"); video_pkt_profiler = Profiler("vidpkt_parse"); audio_pkt_profiler = Profiler("audpkt_parse"); ts_header_profiler = Profiler("tshdr_parse"); pat_parse_timer = Profiler("pathdr_parse"); pmt_parse_timer = Profiler("pmthdr_parse"); // skip_timer = Profiler("skip2end_time"); level1_timer = Profiler("level1_timer"); level2_timer = Profiler("level2_timer"); pmt_pid = 0; video_pid = 0; audio_pid = 0; }
} static PyMethodDef profiler_methods[] = { {"getstats", (PyCFunction)profiler_getstats, METH_NOARGS, getstats_doc}, {"enable", (PyCFunction)profiler_enable, METH_VARARGS | METH_KEYWORDS, enable_doc}, {"disable", (PyCFunction)profiler_disable, METH_NOARGS, disable_doc}, {"clear", (PyCFunction)profiler_clear, METH_NOARGS, clear_doc}, {NULL, NULL} }; PyDoc_STRVAR(profiler_doc, "\ Profiler(custom_timer=None, time_unit=None, subcalls=True, builtins=True)\n\ \n\ Builds a profiler object using the specified timer function.\n\ The default timer is a fast built-in one based on real time.\n\ For custom timer functions returning integers, time_unit can\n\ be a float specifying a scale (i.e. how long each integer unit\n\ is, in seconds).\n\ "); statichere PyTypeObject PyProfiler_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "_lsprof.Profiler", /* tp_name */ sizeof(ProfilerObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)profiler_dealloc, /* tp_dealloc */
/*! @brief The sense->move main loop When signalled the thread will quickly grab the new sensor data, compute a response, and then send the commands to the actionators. Note that you can not safely use the job interface in this thread, if you need to add jobs provide a process function for this thread, and *another* process for the behaviour thread which creates the jobs. */ void SeeThinkThread::run() { #if DEBUG_VERBOSITY > 0 debug << "SeeThinkThread::run()" << endl; #endif #ifdef THREAD_SEETHINK_PROFILE Profiler prof = Profiler("SeeThinkThread"); #endif int err = 0; while (err == 0 && errno != EINTR) { try { #if defined(TARGET_IS_NAOWEBOTS) or (not defined(USE_VISION)) wait(); #endif #ifdef USE_VISION m_nubot->m_platform->updateImage(); *(m_nubot->m_io) << m_nubot; //<! Raw IMAGE STREAMING (TCP) #endif #ifdef THREAD_SEETHINK_PROFILE prof.start(); #endif // ----------------------------------------------------------------------------------------------------------------------------------------------------------------- #ifdef USE_VISION m_nubot->m_vision->ProcessFrame(Blackboard->Image, Blackboard->Sensors, Blackboard->Actions, Blackboard->Objects); #ifdef THREAD_SEETHINK_PROFILE prof.split("vision"); #endif #endif double current_time = Blackboard->Sensors->GetTimestamp(); Blackboard->TeamInfo->UpdateTime(current_time); Blackboard->GameInfo->UpdateTime(current_time); m_logrecorder->WriteData(Blackboard); #ifdef USE_LOCALISATION m_nubot->m_localisation->process(Blackboard->Sensors, Blackboard->Objects, Blackboard->GameInfo, Blackboard->TeamInfo); #ifdef THREAD_SEETHINK_PROFILE prof.split("localisation"); #endif #endif #if defined(USE_BEHAVIOUR) m_nubot->m_behaviour->process(Blackboard->Jobs, Blackboard->Sensors, Blackboard->Actions, Blackboard->Objects, Blackboard->GameInfo, Blackboard->TeamInfo); #ifdef THREAD_SEETHINK_PROFILE prof.split("behaviour"); #endif #endif #if DEBUG_VERBOSITY > 0 Blackboard->Jobs->summaryTo(debug); #endif #ifdef USE_VISION m_nubot->m_vision->process(Blackboard->Jobs) ; //<! Networking for Vision m_nubot->m_platform->process(Blackboard->Jobs, m_nubot->m_io); //<! Networking for Platform #ifdef THREAD_SEETHINK_PROFILE prof.split("vision_jobs"); #endif #endif #ifdef USE_MOTION m_nubot->m_motion->process(Blackboard->Jobs); #ifdef THREAD_SEETHINK_PROFILE prof.split("motion_jobs"); #endif #endif // ----------------------------------------------------------------------------------------------------------------------------------------------------------------- #ifdef THREAD_SEETHINK_PROFILE debug << prof; #endif } catch (std::exception& e) { m_nubot->unhandledExceptionHandler(e); } } errorlog << "SeeThinkThread is exiting. err: " << err << " errno: " << errno << endl; }
//----------------------------------------------------------------------- Root::Root(const String& pluginFileName, const String& configFileName, const String& logFileName) : mLogManager(0) , mRenderSystemCapabilitiesManager(0) , mNextFrame(0) , mFrameSmoothingTime(0.0f) , mNextMovableObjectTypeFlag(1) , mIsInitialised(false) { // superclass will do singleton checking String msg; // Init mActiveRenderer = 0; mVersion = StringConverter::toString(OGRE_VERSION_MAJOR) + "." + StringConverter::toString(OGRE_VERSION_MINOR) + "." + StringConverter::toString(OGRE_VERSION_PATCH) + OGRE_VERSION_SUFFIX + " " + "(" + OGRE_VERSION_NAME + ")"; mConfigFileName = configFileName; // Create log manager and default log file if there is no log manager yet if(LogManager::getSingletonPtr() == 0) { mLogManager = OGRE_NEW LogManager(); mLogManager->createLog(logFileName, true, true); } // Dynamic library manager mDynLibManager = OGRE_NEW DynLibManager(); mArchiveManager = OGRE_NEW ArchiveManager(); // ResourceGroupManager mResourceGroupManager = OGRE_NEW ResourceGroupManager(); // ResourceBackgroundQueue mResourceBackgroundQueue = OGRE_NEW ResourceBackgroundQueue(); // Create SceneManager enumerator (note - will be managed by singleton) mSceneManagerEnum = OGRE_NEW SceneManagerEnumerator(); mCurrentSceneManager = NULL; mShadowTextureManager = OGRE_NEW ShadowTextureManager(); mRenderSystemCapabilitiesManager = OGRE_NEW RenderSystemCapabilitiesManager(); // ..material manager mMaterialManager = OGRE_NEW MaterialManager(); // Mesh manager mMeshManager = OGRE_NEW MeshManager(); // Skeleton manager mSkeletonManager = OGRE_NEW SkeletonManager(); // ..particle system manager mParticleManager = OGRE_NEW ParticleSystemManager(); // Compiler manager //mCompilerManager = OGRE_NEW ScriptCompilerManager(); mTimer = OGRE_NEW Timer(); // Overlay manager mOverlayManager = OGRE_NEW OverlayManager(); mPanelFactory = OGRE_NEW PanelOverlayElementFactory(); mOverlayManager->addOverlayElementFactory(mPanelFactory); mBorderPanelFactory = OGRE_NEW BorderPanelOverlayElementFactory(); mOverlayManager->addOverlayElementFactory(mBorderPanelFactory); mTextAreaFactory = OGRE_NEW TextAreaOverlayElementFactory(); mOverlayManager->addOverlayElementFactory(mTextAreaFactory); // Font manager mFontManager = OGRE_NEW FontManager(); #if OGRE_PROFILING // Profiler mProfiler = OGRE_NEW Profiler(); Profiler::getSingleton().setTimer(mTimer); #endif mFileSystemArchiveFactory = OGRE_NEW FileSystemArchiveFactory(); ArchiveManager::getSingleton().addArchiveFactory( mFileSystemArchiveFactory ); mZipArchiveFactory = OGRE_NEW ZipArchiveFactory(); ArchiveManager::getSingleton().addArchiveFactory( mZipArchiveFactory ); #if OGRE_NO_FREEIMAGE == 0 // Register image codecs FreeImageCodec::startup(); #endif #if OGRE_NO_DEVIL == 0 // Register image codecs ILCodecs::registerCodecs(); #endif #if OGRE_NO_DDS_CODEC == 0 // Register image codecs DDSCodec::startup(); #endif mHighLevelGpuProgramManager = OGRE_NEW HighLevelGpuProgramManager(); mExternalTextureSourceManager = OGRE_NEW ExternalTextureSourceManager(); mCompositorManager = OGRE_NEW CompositorManager(); mCompilerManager = OGRE_NEW ScriptCompilerManager(); // Auto window mAutoWindow = 0; // instantiate and register base movable factories mEntityFactory = OGRE_NEW EntityFactory(); addMovableObjectFactory(mEntityFactory); mLightFactory = OGRE_NEW LightFactory(); addMovableObjectFactory(mLightFactory); mBillboardSetFactory = OGRE_NEW BillboardSetFactory(); addMovableObjectFactory(mBillboardSetFactory); mManualObjectFactory = OGRE_NEW ManualObjectFactory(); addMovableObjectFactory(mManualObjectFactory); mBillboardChainFactory = OGRE_NEW BillboardChainFactory(); addMovableObjectFactory(mBillboardChainFactory); mRibbonTrailFactory = OGRE_NEW RibbonTrailFactory(); addMovableObjectFactory(mRibbonTrailFactory); // Load plugins if (!pluginFileName.empty()) loadPlugins(pluginFileName); LogManager::getSingleton().logMessage("*-*-* OGRE Initialising"); msg = "*-*-* Version " + mVersion; LogManager::getSingleton().logMessage(msg); // Can't create managers until initialised mControllerManager = 0; mFirstTimePostWindowInit = false; }
// run void SAppBase::run() { if (!m_bInit) { // always do last SetWindowLongPtr(m_hWnd, GWL_USERDATA, (LONG)(DWORD_PTR)this); m_bInit = true; } if (!m_bRun) { m_bRun = true; ShowWindow(m_hWnd, SW_SHOW); } // setup startup dialog if not running because of exception if (!m_bException) { std::string cmdLineDlg = getCmdLineOption("d"); try { DialogMgr().add(cmdLineDlg); } catch (ExceptionDialogMgr&) { if (!m_defaultDlg.empty()) DialogMgr().add(m_defaultDlg); } DialogMgr().update(0.0001f); } // init timer timer().endFrame(); bool bNeedsUpdate = false; MSG msg; do { Critical(*m_criticalMainLoop); // windows message handling while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { if (msg.message == WM_QUIT) m_bExit = true; TranslateMessage( &msg ); DispatchMessage( &msg ); } if (m_bExit) break; // game update float delta = (float)(timer().realTime() - m_lastUpdateTime); bNeedsUpdate = m_updateLoopFreq == 0 || delta >= (1.0f / m_updateLoopFreq); if (bNeedsUpdate) { timer().endFrame(); double startFrameTime = timer().realTime(); m_lastUpdateTime = startFrameTime; delta = (float)timer().frame(); { Profile("Dialog Update"); Input().update(); DialogMgr().update(delta); } { Profile("Update"); update(delta); SteppableThreadHost::update(); } Input().clear(); { Profile("Render"); render(); } { Profile("Garbage"); ptrGCManager.garbage->collect(); } m_totalFrameTime = timer().realTime() - startFrameTime; Profiler().end(); Profiler().finalise(); Profiler().start("Total"); } } while (!m_bExit); m_bRun = false; }