From 4673cfd79788c74c5bd6bcabe564c2dfcbd7c553 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 29 Oct 2019 15:10:15 +0100 Subject: Replace the test added by #349 with a bench (#351) CI environments can be noisy and while the test worked great locally on my machine, it didn't on the CI environment. This replaces the test with a (manually tracked) benchmark. As per https://github.com/alexcrichton/toml-rs/pull/349#issuecomment-546998173 --- test-suite/tests/linear.rs | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 test-suite/tests/linear.rs (limited to 'test-suite/tests') diff --git a/test-suite/tests/linear.rs b/test-suite/tests/linear.rs deleted file mode 100644 index dab51f9..0000000 --- a/test-suite/tests/linear.rs +++ /dev/null @@ -1,37 +0,0 @@ -use std::time::{Duration, Instant}; -use toml::Value; - -const TOLERANCE: f64 = 2.0; - -fn measure_time(entries: usize, f: impl Fn(usize) -> String) -> Duration { - let start = Instant::now(); - let mut s = String::new(); - for i in 0..entries { - s += &f(i); - s += "entry = 42\n" - } - s.parse::().unwrap(); - Instant::now() - start -} - -#[test] -fn linear_increase_map() { - let time_1 = measure_time(100, |i| format!("[header_no_{}]\n", i)); - let time_4 = measure_time(400, |i| format!("[header_no_{}]\n", i)); - dbg!(time_1, time_4); - // Now ensure that the deserialization time has increased linearly - // (within a tolerance interval) instead of, say, quadratically - assert!(time_4 > time_1.mul_f64(4.0 - TOLERANCE)); - assert!(time_4 < time_1.mul_f64(4.0 + TOLERANCE)); -} - -#[test] -fn linear_increase_array() { - let time_1 = measure_time(100, |i| format!("[[header_no_{}]]\n", i)); - let time_4 = measure_time(400, |i| format!("[[header_no_{}]]\n", i)); - dbg!(time_1, time_4); - // Now ensure that the deserialization time has increased linearly - // (within a tolerance interval) instead of, say, quadratically - assert!(time_4 > time_1.mul_f64(4.0 - TOLERANCE)); - assert!(time_4 < time_1.mul_f64(4.0 + TOLERANCE)); -} -- cgit v1.2.3