ulf.schroeter Posted March 19, 2011 Share Posted March 19, 2011 Proposal For tracking down code section hot-spots within a function some special EngineAnalyser macro e.g. ENGINE_ANALYZER_SECTION might be helpful. This would allow section timing outputs to console via "engine_analyser" command. quick-and-dirty implementation in EngineAnalyser.h #ifdef NDEBUG .... #define ENGINE_ANALYZER_SECTION(TYPE,FUNCTION,ARGS,SECTION,SECTIONNAME) (static_cast<void>(0)) .... #else .... #define ENGINE_ANALYZER_SECTION(TYPE,FUNCTION,ARGS,SECTION,SECTIONNAME) EngineAnalyzerLock engine_analyzer_lock(#FUNCTION # ARGS " section " # SECTIONNAME, (const unsigned char*)((SECTION) + 256 + (size_t) GetFunctionPointer(TYPE &FUNCTION))); ... #endif Maybe there is a much more elegant solution for avoiding current manual section number and redundant function signature specification requirement...go for it, Alexander Usage Example Searching performance hot-spots for world update void World::update_multiple(float ifps) { ENGINE_ANALYZER(,World::update_multiple,()); .... // update nodes { ENGINE_ANALYZER_SECTION(,World::update_multiple,(),0,update); // ENGINE_ANALYZER_SECTION(update) would be nicer int id = engine.threads->runJobs(update_jobs + 1,sizeof(WorldUpdateJob),num_threads - 1); update_jobs[0].process(); engine.threads->waitJobs(id); } // flush nodes { ENGINE_ANALYZER_SECTION(,World::update_multiple,(),1,flush); // flush update nodes for(int i = 0; i < num_threads; i++) { update_jobs[i].flush(); } } } This would reveal for the following example that most of total function time is spend for node flushing (BTW caused by spatial update of large vegetation node counts generated by WorldClutter) Link to comment
Recommended Posts