Skip to content

Commit

Permalink
Merge pull request #19 from danielparks/fewer-entities
Browse files Browse the repository at this point in the history
Don’t use _all_ HTML entities in tests
  • Loading branch information
danielparks committed Mar 17, 2023
2 parents eb523d6 + 227871a commit 0711716
Show file tree
Hide file tree
Showing 247 changed files with 13,668 additions and 85,004 deletions.
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \

ENV PATH=/root/.cargo/bin:$PATH

# Prevent missing files (https://github.com/danielparks/matchgen/issues/14).
# This won’t affect iai output since it puts stuff in matchgen_tests/target. Of
# course, it might be affected by the bug, but at least that would provide more
# data about the problem.
ENV CARGO_TARGET_DIR=/root/target

COPY . /work
WORKDIR /work
RUN cargo build --benches --profile bench --all-features
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 0711716

Please sign in to comment.