Baloo
10 #include "timeestimator.h"
11 #include "filecontentindexerprovider.h"
13 using namespace Baloo;
15 TimeEstimator::TimeEstimator(
QObject* parent)
18 , m_estimateReady(false)
22 uint TimeEstimator::calculateTimeLeft(
int filesLeft)
24 if (!m_estimateReady) {
29 float totalWeight = 0;
31 int bufferIndex = m_bufferIndex;
32 for (
int i = 0; i < BUFFER_SIZE; ++i) {
33 float weight = sqrt(i + 1);
34 totalWeight += weight;
36 totalTime += m_batchTimeBuffer[bufferIndex] * weight;
37 bufferIndex = (bufferIndex + 1) % BUFFER_SIZE;
40 float weightedAverage = totalTime / totalWeight;
42 return weightedAverage * filesLeft;
45 void TimeEstimator::handleNewBatchTime(uint time, uint batchSize)
48 m_batchTimeBuffer[m_bufferIndex] = (float)time / batchSize;
50 m_bufferIndex = (m_bufferIndex + 1) % BUFFER_SIZE;
52 if (!m_estimateReady && m_bufferIndex == 0) {
54 m_estimateReady =
true;
58 #include "moc_timeestimator.cpp"
Implements storage for docIds without any associated data Instantiated for:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:56:26 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.