-
Notifications
You must be signed in to change notification settings - Fork 0
/
ohm_cpu_clock.rs
51 lines (51 loc) · 1.56 KB
/
ohm_cpu_clock.rs
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
#[tokio::main]
async fn main() -> e_utils::AnyResult<()> {
#[cfg(all(feature = "ohm", target_os = "windows"))]
{
use hw::api_test::Tester;
use hw::{
api_test::{HardwareType, Inner, SensorType, TestCore, TestParams, TestResults, LOAD_CONTROLLER},
wmic::HardwareMonitor as _,
};
let params = TestParams {
test_secs: 3,
v1: 3000.0,
v2: 5000.0,
v3: 100.0,
};
let mut results = TestResults::new();
results.hw_type = HardwareType::CPU;
results.sensor_type = SensorType::Clock;
let mut tester = Tester {
inner: Inner::OHM(hw::ohm::OHM::new()?),
core: TestCore {
results,
params,
core_count: 0,
is_full: true,
is_check: false,
is_print: false,
is_data: true,
},
};
let pids = hw::common::process::run("OpenHardwareMonitor.exe", std::env::current_dir()?)?;
hw::ohm::OHM::test(100)?;
tester.core.core_count = tester.inner.get_cpu_core_count().await?;
let load_handles = tester.spawn_load()?;
let res = tester.run().await;
hw::common::process::kill(pids)?;
LOAD_CONTROLLER.stop_running();
for handle in load_handles {
handle.join().unwrap();
}
tester = res?;
if tester.core.results.data.is_empty() && tester.core.is_check {
tester.core.results.res = "FAIL".to_string();
return Err(format!("{} {} 测试失败", tester.core.hw_name(), tester.core.sensor_name()).into());
} else {
tester.core.results.res = "PASS".to_string();
}
hw::p(tester.get_test_summary());
}
Ok(())
}