chesspenguin --bench: timings of a database on this machine; memory probe via sysinfo
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
a7d9d599aa
commit
1506ebdf26
8 changed files with 312 additions and 2 deletions
19
crates/chess-import/src/memory.rs
Normal file
19
crates/chess-import/src/memory.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//! What the machine has: total and available memory, for choosing between keeping
|
||||
//! an index in memory and reading it from disk (and for the bench report).
|
||||
|
||||
use sysinfo::{MemoryRefreshKind, RefreshKind, System};
|
||||
|
||||
fn system() -> System {
|
||||
System::new_with_specifics(RefreshKind::nothing().with_memory(MemoryRefreshKind::everything()))
|
||||
}
|
||||
|
||||
/// Bytes of memory the system reports as available to new allocations without
|
||||
/// swapping (Linux `MemAvailable`; the other systems' equivalent). `None` when unknown.
|
||||
pub fn available() -> Option<u64> {
|
||||
Some(system().available_memory()).filter(|n| *n > 0)
|
||||
}
|
||||
|
||||
/// Bytes of physical memory.
|
||||
pub fn total() -> Option<u64> {
|
||||
Some(system().total_memory()).filter(|n| *n > 0)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue