Skip to content

Commit

Permalink
Don’t use _all_ HTML entities in tests
Browse files Browse the repository at this point in the history
Building matchers for all HTML entities can be a bit much for limited
hosts, e.g. micro VMs or limited Docker containers. This removes most of
the HTML entities; it only keeps entites that are all lowercase and
whose names start with one of `[aglqt]`.

### To do

* [ ] Criterion benchmarks
  • Loading branch information
danielparks committed Mar 17, 2023
1 parent eb523d6 commit 8ca0571
Show file tree
Hide file tree
Showing 22 changed files with 10,912 additions and 12,508 deletions.
4 changes: 2 additions & 2 deletions matchgen_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ paste = "1.0.11"
bench = false

[[bench]]
name = "all_entity_decode_iai"
name = "most_entity_decode_iai"
harness = false
required-features = ["iai"]

[[bench]]
name = "all_entity_decode"
name = "most_entity_decode"
harness = false
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ macro_rules! benchmark {
let input = $input;
$group.throughput(Throughput::Bytes(input.len().try_into().unwrap()));
$group.bench_with_input(
BenchmarkId::new("all_entity_decode", $test_name),
BenchmarkId::new("most_entity_decode", $test_name),
input,
|b, input| {
b.iter(|| {
let mut iter = input.iter();
all_entity_decode(&mut iter)
most_entity_decode(&mut iter)
})
},
);
$group.bench_with_input(
BenchmarkId::new("all_entity_decode_slice", $test_name),
BenchmarkId::new("most_entity_decode_slice", $test_name),
input,
|b, input| b.iter(|| all_entity_decode_slice(input)),
|b, input| b.iter(|| most_entity_decode_slice(input)),
);
}};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ macro_rules! iai_benchmarks {
fn [<$name _iter>]() -> Option<&'static str> {
let input = black_box($input);
let mut iter = input.iter();
black_box(all_entity_decode(&mut iter))
black_box(most_entity_decode(&mut iter))
}

fn [<$name _slice>]() -> (Option<&'static str>, &'static [u8]) {
black_box(all_entity_decode_slice(
black_box(most_entity_decode_slice(
black_box($input.as_slice())
))
}
Expand Down
10 changes: 5 additions & 5 deletions matchgen_tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ fn main() -> Result<(), Box<dyn Error>> {
.render(&mut out)?;
writeln!(out)?;

writeln!(out, "/// Decode all HTML entities.")?;
let input = fs::read("html-entities.json")?;
writeln!(out, "/// Decode most HTML entities.")?;
let input = fs::read("most-html-entities.json")?;
let input: serde_json::Map<String, serde_json::Value> =
serde_json::from_slice(&input)?;
let mut matcher =
TreeMatcher::new("pub fn all_entity_decode", "&'static str");
TreeMatcher::new("pub fn most_entity_decode", "&'static str");
matcher
.disable_clippy(true)
.set_input_type(Input::Iterator)
Expand All @@ -101,8 +101,8 @@ fn main() -> Result<(), Box<dyn Error>> {
matcher.render(&mut out)?;
writeln!(out)?;

writeln!(out, "/// Decode all HTML entities.")?;
matcher.fn_name = "pub fn all_entity_decode_slice".to_string();
writeln!(out, "/// Decode most HTML entities.")?;
matcher.fn_name = "pub fn most_entity_decode_slice".to_string();
matcher.set_input_type(Input::Slice);
matcher.render(&mut out)?;
writeln!(out)?;
Expand Down
2,233 changes: 0 additions & 2,233 deletions matchgen_tests/html-entities.json

This file was deleted.

371 changes: 371 additions & 0 deletions matchgen_tests/most-html-entities.json

Large diffs are not rendered by default.

Loading

0 comments on commit 8ca0571

Please sign in to comment.