-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.rs
More file actions
58 lines (48 loc) · 1.57 KB
/
model.rs
File metadata and controls
58 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use std::collections::VecDeque;
#[derive(Debug, Copy, Clone)]
pub struct CpuId(pub u8);
impl CpuId {
pub(crate) fn path_for(&self, path: &str) -> std::string::String {
path.replace("{}", &self.0.to_string())
}
}
#[derive(Debug, Clone)]
pub(crate) struct CpuFrequencyHistory {
pub(crate) running: bool,
pub(crate) history: usize,
pub(crate) min_value: u32,
pub(crate) max_value: u32,
pub(crate) data: Vec<VecDeque<u32>>,
}
impl CpuFrequencyHistory {
pub(crate) fn new(cpu_count: usize, history: usize, min_value: u32, max_value: u32) -> Self {
Self {
running: true,
history,
min_value,
max_value,
data: vec![VecDeque::from(vec![0u32; history]); cpu_count],
}
}
pub(crate) fn append(&mut self, values: Vec<u32>) {
for (cpu, new_value) in values.into_iter().enumerate() {
let cpu_data = self
.data
.get_mut(cpu)
.expect("Mismatch between struct and append data shape");
cpu_data.pop_front();
cpu_data.push_back(new_value);
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct ScalingGovernor(pub std::string::String);
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct EnergyPerformancePreference(pub std::string::String);
pub(crate) trait AllowedValues: Sized {
fn new(value: std::string::String) -> anyhow::Result<Self>;
fn all() -> Vec<std::string::String>;
fn valid(value: &std::string::String) -> bool {
Self::all().contains(value)
}
}