void DrawProfiler::finishFrame() { RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].swapBuffers = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; mCurrentFrame = (mCurrentFrame + 1) % mDataSize; }
void DrawProfiler::dumpData(int fd) { RETURN_IF_PROFILING_DISABLED(); // This method logs the last N frames (where N is <= mDataSize) since the // last call to dumpData(). In other words if there's a dumpData(), draw frame, // dumpData(), the last dumpData() should only log 1 frame. const FrameTimingData emptyData = {0, 0, 0, 0}; FILE *file = fdopen(fd, "a"); fprintf(file, "\n\tDraw\tPrepare\tProcess\tExecute\n"); for (int frameOffset = 1; frameOffset <= mDataSize; frameOffset++) { int i = (mCurrentFrame + frameOffset) % mDataSize; if (!memcmp(mData + i, &emptyData, sizeof(FrameTimingData))) { continue; } fprintf(file, "\t%3.2f\t%3.2f\t%3.2f\t%3.2f\n", mData[i].record, mData[i].prepare, mData[i].playback, mData[i].swapBuffers); } // reset the buffer memset(mData, 0, sizeof(FrameTimingData) * mDataSize); mCurrentFrame = 0; fflush(file); }
void FrameInfoVisualizer::dumpData(int fd) { RETURN_IF_PROFILING_DISABLED(); // This method logs the last N frames (where N is <= mDataSize) since the // last call to dumpData(). In other words if there's a dumpData(), draw frame, // dumpData(), the last dumpData() should only log 1 frame. dprintf(fd, "\n\tDraw\tPrepare\tProcess\tExecute\n"); for (size_t i = 0; i < mFrameSource.size(); i++) { if (mFrameSource[i][FrameInfoIndex::IntendedVsync] <= mLastFrameLogged) { continue; } mLastFrameLogged = mFrameSource[i][FrameInfoIndex::IntendedVsync]; dprintf(fd, "\t%3.2f\t%3.2f\t%3.2f\t%3.2f\n", durationMS(i, FrameInfoIndex::IntendedVsync, FrameInfoIndex::SyncStart), durationMS(i, FrameInfoIndex::SyncStart, FrameInfoIndex::IssueDrawCommandsStart), durationMS(i, FrameInfoIndex::IssueDrawCommandsStart, FrameInfoIndex::SwapBuffers), durationMS(i, FrameInfoIndex::SwapBuffers, FrameInfoIndex::FrameCompleted)); } }
void DrawProfiler::markPlaybackEnd() { RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].playback = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; }
void DrawProfiler::startFrame(nsecs_t recordDurationNanos) { RETURN_IF_PROFILING_DISABLED(); mData[mCurrentFrame].record = NANOS_TO_MILLIS_FLOAT(recordDurationNanos); mPreviousTime = systemTime(CLOCK_MONOTONIC); }