1/*
2 This file is part of the KDE Baloo Project
3 SPDX-FileCopyrightText: 2015 Pinak Ahuja <pinak.ahuja@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef BALOO_TIMEESTIMATOR_H
9#define BALOO_TIMEESTIMATOR_H
10
11#define BUFFER_SIZE 5
12
13#include <QtGlobal>
14
15namespace Baloo {
16/*
17* This class handles the time estimation logic for filecontentindexer.
18* Time estimations use a weighted moving average of the time taken by
19* 5 most recent batches. The more recent the batch is, higher the weight
20* it will be assigned.
21*/
22
23class TimeEstimator
24{
25public:
26 TimeEstimator();
27 uint calculateTimeLeft(int filesLeft);
28
29 void handleNewBatchTime(uint time, uint batchSize);
30
31private:
32 float m_batchTimeBuffer[BUFFER_SIZE];
33
34 int m_bufferIndex = 0;
35 bool m_estimateReady = false;
36};
37
38}
39
40#endif //BALOO_TIMEESTIMATOR_H
41

source code of baloo/src/file/timeestimator.h