bool Jitterometer::RecordEndTime() { if (!num_cycles) return false; int cycles = num_cycles; struct timeval timenow; gettimeofday(&timenow, NULL); if (starttime_valid) { times[count] = (timenow.tv_sec - starttime.tv_sec ) * 1000000 + (timenow.tv_usec - starttime.tv_usec) ; count++; } starttime_valid = 0; if (count >= cycles) { /* compute and display stuff, reset count to -1 */ double mean = 0, sum_of_squared_deviations=0; double standard_deviation; double tottime = 0; int i; /* compute the mean */ for(i = 0; i < cycles; i++) mean += times[i]; tottime = mean; mean /= cycles; if (tottime > 0) last_fps = cycles / tottime * 1000000; /* compute the sum of the squares of each deviation from the mean */ for(i = 0; i < cycles; i++) sum_of_squared_deviations += (mean - times[i]) * (mean - times[i]); /* compute standard deviation */ standard_deviation = sqrt(sum_of_squared_deviations / (cycles - 1)); if (mean > 0) last_sd = standard_deviation / mean; /* retrieve load if available */ QString extra; lastcpustats = GetCPUStat(); if (!lastcpustats.isEmpty()) extra = QString("CPUs: ") + lastcpustats; LOG(VB_PLAYBACK, LOG_INFO, name + QString("Mean: %1 Std.Dev: %2 fps: %3 ") .arg((int)mean).arg((int)standard_deviation) .arg(last_fps, 0, 'f', 2) + extra); count = 0; return true; } return false; }
bool Jitterometer::RecordEndTime() { if (!m_num_cycles) return false; int cycles = m_num_cycles; struct timeval timenow; gettimeofday(&timenow, nullptr); if (m_starttime_valid) { m_times[m_count] = (timenow.tv_sec - m_starttime.tv_sec ) * 1000000 + (timenow.tv_usec - m_starttime.tv_usec) ; m_count++; } m_starttime_valid = false; if (m_count >= cycles) { /* compute and display stuff, reset count to -1 */ double mean = 0, sum_of_squared_deviations=0; double standard_deviation; double tottime = 0; int i; /* compute the mean */ for(i = 0; i < cycles; i++) mean += m_times[i]; tottime = mean; mean /= cycles; if (tottime > 0) m_last_fps = cycles / tottime * 1000000; /* compute the sum of the squares of each deviation from the mean */ for(i = 0; i < cycles; i++) sum_of_squared_deviations += (mean - m_times[i]) * (mean - m_times[i]); /* compute standard deviation */ standard_deviation = sqrt(sum_of_squared_deviations / (cycles - 1)); if (mean > 0) m_last_sd = standard_deviation / mean; /* retrieve load if available */ QString extra; m_lastcpustats = GetCPUStat(); if (!m_lastcpustats.isEmpty()) extra = QString("CPUs: ") + m_lastcpustats; LOG(VB_GENERAL, LOG_INFO, m_name + QString("FPS: %1 Mean: %2 Std.Dev: %3 ") .arg(m_last_fps, 7, 'f', 2).arg((int)mean, 5) .arg((int)standard_deviation, 5) + extra); m_count = 0; return true; } return false; }
void UIPerformance::RecordEndTime(quint64 Time) { if (!m_totalCount) return; int cycles = m_totalCount; if (m_starttimeValid) { m_totalTimes[m_currentCount] = Time - m_starttime; m_currentCount++; } m_starttimeValid = false; if (m_currentCount >= cycles) { qreal totalmean = 0.0; qreal rendermean = 0.0; for(int i = 0; i < cycles; i++) { rendermean += m_renderTimes[i]; totalmean += m_totalTimes[i]; } if (totalmean > 0) m_lastFPS = (cycles / totalmean) * 1000000.0; totalmean /= cycles; rendermean /= cycles; qreal totaldeviations = 0.0; qreal renderdeviations = 0.0; for(int i = 0; i < cycles; i++) { renderdeviations += (rendermean - m_renderTimes[i]) * (rendermean - m_renderTimes[i]); totaldeviations += (totalmean - m_totalTimes[i]) * (totalmean - m_totalTimes[i]); } qreal rendersd = sqrt(renderdeviations / (cycles - 1)); qreal totalsd = sqrt(totaldeviations / (cycles - 1)); if (totalmean > 0.0) m_lastTotalSD = totalsd / totalmean; if (rendermean > 0.0) m_lastRenderSD = rendersd / rendermean; QString extra; m_lastCPUStats = GetCPUStat(); if (!m_lastCPUStats.isEmpty()) extra = QString("Load: ") + m_lastCPUStats; LOG(VB_GUI, LOG_INFO, QString("FPS: %1+-%3 Draw: %4% ") .arg(m_lastFPS, 4, 'f', 3) .arg(m_lastTotalSD, 2, 'f', 2) .arg((rendermean / totalmean) * 100.0, 2, 'f', 0) + extra); m_currentCount = 0; return; } return; }