Skip to content

Commit 9fdfe40

Browse files
author
swifty
committed
Fix typo
1 parent ab6a503 commit 9fdfe40

File tree

3 files changed

+42
-65
lines changed

3 files changed

+42
-65
lines changed

Cargo.lock

Lines changed: 0 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ lazy_static = "1.5.0"
1616
sysinfo = "0.33.1"
1717
colored = "3.0.0"
1818
plotters = "0.3.7"
19-
crossbeam = "0.8.4"
2019
comfy-table = "7.1.3"
21-
crossterm = "0.28.1"
20+
2221

2322
[dependencies.windows]
2423
version = "0.59.0"

src/main.rs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,31 +398,67 @@ lazy_static::lazy_static! {
398398
fn check_hpet_status() -> io::Result<()> {
399399
let mut status = HPET_STATUS.lock().unwrap();
400400

401+
// Use the cached status if available.
401402
if let Some(ref cached_status) = *status {
402403
println!("HPET status (cached): {}", cached_status);
403404
return Ok(());
404405
}
405406

407+
// Run the bcdedit command to get the current boot configuration.
406408
let output = Command::new("bcdedit")
407409
.arg("/enum")
408410
.arg("{current}")
409411
.output()?;
410412

413+
if !output.status.success() {
414+
eprintln!("❌ Error: Failed to retrieve HPET status");
415+
return Err(Error::new(ErrorKind::Other, "Failed to retrieve HPET status"));
416+
}
417+
411418
let output_str = String::from_utf8_lossy(&output.stdout);
412-
let mut hpet_status = "disabled";
419+
420+
// We'll capture the values for the two keys if they exist.
421+
let mut useplatformclock_value: Option<String> = None;
422+
let mut disabledynamictick_value: Option<String> = None;
423+
413424
for line in output_str.lines() {
414-
if line.contains("useplatformtick=no") || line.contains("disabledynamictick=yes") {
415-
hpet_status = "enabled";
416-
break;
425+
let mut parts = line.split_whitespace();
426+
if let (Some(key), Some(value)) = (parts.next(), parts.next()) {
427+
match key.to_lowercase().as_str() {
428+
"useplatformclock" => {
429+
useplatformclock_value = Some(value.to_lowercase());
430+
}
431+
"disabledynamictick" => {
432+
disabledynamictick_value = Some(value.to_lowercase());
433+
}
434+
_ => {}
435+
}
417436
}
418437
}
419438

439+
// Decide HPET status.
440+
// According to the requirement, if "useplatformclock" is absent and "disabledynamictick" is "yes",
441+
// then we consider HPET as disabled.
442+
let hpet_status = match (
443+
useplatformclock_value.as_deref(),
444+
disabledynamictick_value.as_deref(),
445+
) {
446+
// If "useplatformclock" is present and equals "no", and disabledynamictick is "yes" → disabled.
447+
(Some("no"), Some("yes")) => "disabled",
448+
// If "useplatformclock" is absent but disabledynamictick is "yes" → disabled.
449+
(None, Some("yes")) => "disabled",
450+
// If both keys are absent, default to disabled.
451+
(None, None) => "disabled",
452+
// In all other cases, consider HPET as enabled.
453+
_ => "enabled",
454+
};
455+
420456
println!("HPET status: {}", hpet_status);
421457

458+
// If HPET is enabled, notify the user and prompt to disable.
422459
if hpet_status == "enabled" {
423460
println!("⚠️ HPET is enabled. For optimal results, it is recommended to disable HPET.");
424461
println!("Please refer to the troubleshooting guide: https://github.com/SwiftyPop/TimerResBenchmark?tab=readme-ov-file#troubleshooting");
425-
426462
println!("Would you like to disable HPET now? (y/n): ");
427463
let mut input = String::new();
428464
io::stdin().read_line(&mut input)?;

0 commit comments

Comments
 (0)