Baloo

timeestimator.h
1 /*
2  This file is part of the KDE Baloo Project
3  SPDX-FileCopyrightText: 2015 Pinak Ahuja <[email protected]>
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 "fileindexerconfig.h"
14 #include <QObject>
15 
16 namespace Baloo {
17 /*
18 * This class handles the time estimation logic for filecontentindexer.
19 * Time estimations use a weighted moving average of the time taken by
20 * 5 most recent batches. The more recent the batch is, higher the weight
21 * it will be assigned.
22 */
23 
24 class TimeEstimator : public QObject
25 {
26  Q_OBJECT
27 public:
28  explicit TimeEstimator(QObject* parent = nullptr);
29  uint calculateTimeLeft(int filesLeft);
30 
31 public Q_SLOTS:
32  void handleNewBatchTime(uint time, uint batchSize);
33 
34 private:
35  float m_batchTimeBuffer[BUFFER_SIZE];
36 
37  int m_bufferIndex;
38  bool m_estimateReady;
39 };
40 
41 }
42 
43 #endif //BALOO_TIMEESTIMATOR_H
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 03:53:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.