Merge pull request #275 from jonathandturner/fix_ghz

Clean up ghz view
This commit is contained in:
Jonathan Turner 2019-08-11 15:48:45 +12:00 committed by GitHub
commit d50aa81be6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,12 +26,19 @@ async fn cpu(tag: Tag) -> Option<Tagged<Value>> {
) { ) {
let mut cpu_idx = TaggedDictBuilder::new(tag); let mut cpu_idx = TaggedDictBuilder::new(tag);
cpu_idx.insert("cores", Primitive::Int(num_cpu as i64)); cpu_idx.insert("cores", Primitive::Int(num_cpu as i64));
cpu_idx.insert("speed", Primitive::Int(cpu_speed.current().get() as i64));
let current_speed =
(cpu_speed.current().get() as f64 / 1000000000.0 * 100.0).round() / 100.0;
cpu_idx.insert("current ghz", Primitive::Float(current_speed.into()));
if let Some(min_speed) = cpu_speed.min() { if let Some(min_speed) = cpu_speed.min() {
cpu_idx.insert("min", Primitive::Int(min_speed.get() as i64)); let min_speed = (min_speed.get() as f64 / 1000000000.0 * 100.0).round() / 100.0;
cpu_idx.insert("min ghz", Primitive::Float(min_speed.into()));
} }
if let Some(max_speed) = cpu_speed.max() { if let Some(max_speed) = cpu_speed.max() {
cpu_idx.insert("max", Primitive::Int(max_speed.get() as i64)); let max_speed = (max_speed.get() as f64 / 1000000000.0 * 100.0).round() / 100.0;
cpu_idx.insert("max ghz", Primitive::Float(max_speed.into()));
} }
Some(cpu_idx.into_tagged_value()) Some(cpu_idx.into_tagged_value())
} else { } else {