Switch to unit-safe quantities

This commit is contained in:
David Peter authored and David Peter committed 2026-10-05 15:58:56 +02:00
1 parent 914d5cbc59
commit f9aa299c0f
15 files changed
+399 -287

No files matched your search

+97 -96
View File
@@ -1,6 +1,7 @@
use super::Exporter;
use crate::benchmark::benchmark_result::BenchmarkResult;
use crate::benchmark::measurement::{Measurement, Measurements};
use crate::benchmark::quantity::{Byte, Second};
use crate::export::asciidoc::AsciidocExporter;
use crate::export::orgmode::OrgmodeExporter;
use crate::quantity::{byte, second, Information, Time, TimeUnit, Zero};
@@ -30,24 +31,24 @@ fn test_markup_export_auto_ms() {
command: String::from("sleep 0.1"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 0.09,
user_time: 0.09,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.09),
user_time: Second::new(0.09),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.10,
user_time: 0.10,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.10),
user_time: Second::new(0.10),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.14,
user_time: 0.14,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.14),
user_time: Second::new(0.14),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),
@@ -57,24 +58,24 @@ fn test_markup_export_auto_ms() {
command: String::from("sleep 2"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 2.0,
user_time: 2.0,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.0),
user_time: Second::new(2.0),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 3.0,
user_time: 3.0,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(3.0),
user_time: Second::new(3.0),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 4.0,
user_time: 4.0,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(4.0),
user_time: Second::new(4.0),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),
@@ -129,24 +130,24 @@ fn test_markup_export_auto_s() {
command: String::from("sleep 2"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 2.1,
user_time: 2.1,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.1),
user_time: Second::new(2.1),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 2.2,
user_time: 2.2,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.2),
user_time: Second::new(2.2),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 2.3,
user_time: 2.3,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.3),
user_time: Second::new(2.3),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),
@@ -156,24 +157,24 @@ fn test_markup_export_auto_s() {
command: String::from("sleep 0.1"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 0.1,
user_time: 0.1,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.1),
user_time: Second::new(0.1),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.2,
user_time: 0.2,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.2),
user_time: Second::new(0.2),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.3,
user_time: 0.3,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.3),
user_time: Second::new(0.3),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),
@@ -228,24 +229,24 @@ fn test_markup_export_manual_ms() {
command: String::from("sleep 2"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 2.1,
user_time: 2.1,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.1),
user_time: Second::new(2.1),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 2.2,
user_time: 2.2,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.2),
user_time: Second::new(2.2),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 2.3,
user_time: 2.3,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.3),
user_time: Second::new(2.3),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),
@@ -255,24 +256,24 @@ fn test_markup_export_manual_ms() {
command: String::from("sleep 0.1"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 0.1,
user_time: 0.1,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.1),
user_time: Second::new(0.1),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.2,
user_time: 0.2,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.2),
user_time: Second::new(0.2),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.3,
user_time: 0.3,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.3),
user_time: Second::new(0.3),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),
@@ -326,24 +327,24 @@ fn test_markup_export_manual_s() {
command: String::from("sleep 2"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 2.01,
user_time: 2.01,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.01),
user_time: Second::new(2.01),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 2.02,
user_time: 2.02,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.02),
user_time: Second::new(2.02),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 2.03,
user_time: 2.03,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(2.03),
user_time: Second::new(2.03),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),
@@ -353,24 +354,24 @@ fn test_markup_export_manual_s() {
command: String::from("sleep 0.1"),
measurements: Measurements::new(vec![
Measurement {
wall_clock_time: 0.11,
user_time: 0.11,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.11),
user_time: Second::new(0.11),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.12,
user_time: 0.12,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.12),
user_time: Second::new(0.12),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
Measurement {
wall_clock_time: 0.13,
user_time: 0.13,
system_time: 0.,
memory_usage_byte: 1024,
wall_clock_time: Second::new(0.13),
user_time: Second::new(0.13),
system_time: Second::zero(),
memory_usage_byte: Byte::new(1024),
exit_code: Some(0),
},
]),