Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
statistics.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <memory>
7
8#include "contur/core/types.h"
9
10namespace contur {
11
14 {
15 public:
18 explicit Statistics(double alpha = 0.5);
19
22
24 Statistics(const Statistics &) = delete;
25
27 Statistics &operator=(const Statistics &) = delete;
29 Statistics(Statistics &&) noexcept;
30
32 Statistics &operator=(Statistics &&) noexcept;
33
35 void recordBurst(ProcessId pid, Tick burst);
36
38 [[nodiscard]] Tick predictedBurst(ProcessId pid) const noexcept;
39
41 [[nodiscard]] bool hasPrediction(ProcessId pid) const noexcept;
42
44 void clear(ProcessId pid);
45
47 void reset();
48
50 [[nodiscard]] double alpha() const noexcept;
51
52 private:
53 struct Impl;
54 std::unique_ptr<Impl> impl_;
55 };
56
57} // namespace contur
Statistics(double alpha=0.5)
Constructs statistics store.
void reset()
Clears statistics for all processes.
Statistics(Statistics &&) noexcept
Move-constructs statistics state.
std::unique_ptr< Impl > impl_
Definition statistics.h:54
void clear(ProcessId pid)
Clears statistics for one process.
~Statistics()
Destroys statistics store.
Statistics(const Statistics &)=delete
Copy construction is disabled.
void recordBurst(ProcessId pid, Tick burst)
Records an observed CPU burst for the process.
bool hasPrediction(ProcessId pid) const noexcept
Returns true if the process already has a prediction.
Statistics & operator=(const Statistics &)=delete
Copy assignment is disabled.
double alpha() const noexcept
Returns EWMA alpha in range (0, 1].
Tick predictedBurst(ProcessId pid) const noexcept
Returns the current predicted burst (0 if unknown).
Definition block.h:15
std::uint64_t Tick
Simulation clock tick counter.
Definition types.h:18
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...