void Profiler::EndFrame() { assert(tasksInProgress_.empty()); // flush it all to disk std::ofstream profileLogStream; if( frameIndex_ == 0 ) { String outPath = FileManager::Get()->GetFullPath( "run.profilelog" ); profileLogStream.open( outPath.c_str(), ios_base::out | ios_base::binary ); int64 timerFrequency = GetTimerFrequency(); profileLogStream.write(reinterpret_cast<const char*>(&timerFrequency), sizeof(timerFrequency)); } else { String outPath = FileManager::Get()->GetFullPath( "run.profilelog" ); profileLogStream.open( outPath.c_str(), ios_base::app | ios_base::out | ios_base::binary ); } if(profileLogStream.is_open()) { profileLogStream.write(reinterpret_cast<const char*>(&frameIndex_), sizeof(frameIndex_)); unsigned int numTasks = completedTasks_.size(); profileLogStream.write(reinterpret_cast<const char*>(&numTasks), sizeof(numTasks)); for(std::vector<ProfilerTask>::const_iterator taskIter = completedTasks_.begin() ; taskIter != completedTasks_.end() ; ++taskIter) { profileLogStream << *taskIter; } profileLogStream.close(); } ++frameIndex_; }
/* get number of seconds since last call to start timer */ double get_timer(){ LARGE_INTEGER tfinish; QueryPerformanceCounter(&tfinish); return ((double)(tfinish.QuadPart-tstart.QuadPart) / GetTimerFrequency()); }