mirror of
https://codeberg.org/icewind/palantir.git
synced 2026-06-04 19:07:13 +02:00
multi gpu
This commit is contained in:
parent
22c82c59af
commit
217933c1a1
15 changed files with 234 additions and 129 deletions
|
|
@ -1,7 +1,9 @@
|
|||
use either::Either;
|
||||
|
||||
use crate::data::{CpuPowerUsage, GpuPowerUsage};
|
||||
use crate::linux::gpu::gpu_power;
|
||||
use crate::linux::hwmon::FileSource;
|
||||
use crate::{IoResultExt, Result, SensorSource};
|
||||
use crate::{IoResultExt, MultiSensorSource, Result, SensorSource};
|
||||
use std::fs::read_dir;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -49,11 +51,13 @@ impl SensorSource for CpuPowerSource {
|
|||
#[derive(Default)]
|
||||
pub struct GpuPowerSource;
|
||||
|
||||
impl SensorSource for GpuPowerSource {
|
||||
impl MultiSensorSource for GpuPowerSource {
|
||||
type Data = GpuPowerUsage;
|
||||
|
||||
fn read(&mut self) -> Result<Self::Data> {
|
||||
let gpu_uj = crate::linux::gpu::nvidia::power().unwrap_or_else(gpu_power);
|
||||
Ok(GpuPowerUsage { gpu_uj })
|
||||
fn read(&mut self) -> Result<impl Iterator<Item = Result<Self::Data>>> {
|
||||
Ok(crate::linux::gpu::nvidia::power()
|
||||
.map(Either::Left)
|
||||
.unwrap_or_else(|| Either::Right(gpu_power()))
|
||||
.map(Ok))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue