10#include "timeestimator.h"
14TimeEstimator::TimeEstimator() =
default;
16uint TimeEstimator::calculateTimeLeft(
int filesLeft)
18 if (!m_estimateReady) {
23 float totalWeight = 0;
25 int bufferIndex = m_bufferIndex;
26 for (
int i = 0; i < BUFFER_SIZE; ++i) {
27 float weight = sqrt(i + 1);
28 totalWeight += weight;
30 totalTime += m_batchTimeBuffer[bufferIndex] * weight;
31 bufferIndex = (bufferIndex + 1) % BUFFER_SIZE;
34 float weightedAverage = totalTime / totalWeight;
36 return weightedAverage * filesLeft;
39void TimeEstimator::handleNewBatchTime(uint time, uint batchSize)
42 m_batchTimeBuffer[m_bufferIndex] = (float)time / batchSize;
44 m_bufferIndex = (m_bufferIndex + 1) % BUFFER_SIZE;
46 if (!m_estimateReady && m_bufferIndex == 0) {
48 m_estimateReady =
true;
Implements storage for docIds without any associated data Instantiated for:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:13 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.