Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add combine-based benchmark that caused a large performance regression #588

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions collector/benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ programs.
- **coercions**: Contains a static array with 65,536 string literals, which
caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
the past.
- **combine**: Contains a small `combine`-based parser that caused a [large
performance regression](https://github.com/rust-lang/rust/issues/67454) in
the past.
- **ctfe-stress-4**: A stress test for compile-time function evaluation.
- **deeply-nested**: A small program that caused [exponential
behavior](https://github.com/rust-lang/rust/issues/38528) in the past.
Expand Down
2 changes: 2 additions & 0 deletions collector/benchmarks/combine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
**/*.rs.bk
62 changes: 62 additions & 0 deletions collector/benchmarks/combine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions collector/benchmarks/combine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "combine-bench"
license = "MIT"
version = "0.1.0"
authors = ["Sebastian Dröge <[email protected]>", "François Laignel <[email protected]>"]
edition = "2018"

[dependencies]
combine = "3.8"
35 changes: 35 additions & 0 deletions collector/benchmarks/combine/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use combine::byte::hex_digit;
use combine::{choice, token};
use combine::{ParseError, Parser, RangeStream};

pub fn parse<'a, I: 'a>() -> impl Parser<Input = I, Output = u8>
where
I: RangeStream<Item = u8, Range = &'a [u8]>,
I::Error: ParseError<I::Item, I::Range, I::Position>,
{
choice!(
token(b'A').map(|_| 1),
token(b'B').map(|_| 2),
token(b'C').map(|_| 3),
token(b'D').map(|_| 4),
token(b'E').map(|_| 5),
token(b'F').map(|_| 6),
token(b'G').map(|_| 7),
token(b'H').map(|_| 8),
token(b'I').map(|_| 9),
token(b'J').map(|_| 10),
token(b'K').map(|_| 11),
token(b'L').map(|_| 12),
token(b'M').map(|_| 13),
token(b'N').map(|_| 14),
token(b'O').map(|_| 15),
token(b'P').map(|_| 16),
token(b'Q').map(|_| 17),
token(b'R').map(|_| 18),
(hex_digit(), hex_digit()).map(|(u, l)| {
let val = (u << 4) | l;
val
})
)
.message("while parsing")
}