This repository has been archived by the owner on Sep 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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 #349 (comment)
- Loading branch information
1 parent
4b05a9d
commit 4673cfd
Showing
4 changed files
with
41 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,12 @@ authors = ["Alex Crichton <[email protected]>"] | |
publish = false | ||
edition = "2018" | ||
|
||
[[bench]] | ||
name = "linear" | ||
harness = false | ||
|
||
[dev-dependencies] | ||
bencher = "0.1" | ||
toml = { path = ".." } | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_derive = "1.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Regressoion test for https://github.com/alexcrichton/toml-rs/issues/342 | ||
|
||
use bencher::{benchmark_group, benchmark_main, black_box, Bencher}; | ||
use toml::Value; | ||
|
||
fn parse(bench: &mut Bencher, entries: usize, f: impl Fn(usize) -> String) { | ||
let mut s = String::new(); | ||
for i in 0..entries { | ||
s += &f(i); | ||
s += "entry = 42\n" | ||
} | ||
let s = black_box(s); | ||
bench.iter(|| { | ||
black_box(s.parse::<Value>().unwrap()); | ||
}) | ||
} | ||
|
||
fn map_10(bench: &mut Bencher) { | ||
parse(bench, 10, |i| format!("[header_no_{}]\n", i)) | ||
} | ||
|
||
fn map_100(bench: &mut Bencher) { | ||
parse(bench, 100, |i| format!("[header_no_{}]\n", i)) | ||
} | ||
|
||
fn array_10(bench: &mut Bencher) { | ||
parse(bench, 10, |_i| "[[header]]\n".to_owned()) | ||
} | ||
|
||
fn array_100(bench: &mut Bencher) { | ||
parse(bench, 100, |_i| "[[header]]\n".to_owned()) | ||
} | ||
|
||
benchmark_group!(benches, map_10, map_100, array_10, array_100); | ||
benchmark_main!(benches); |
This file was deleted.
Oops, something went wrong.