Skip to content

Commit ef7b1b4

Browse files
committed
Add combine-based benchmark that caused a large performance regression
See rust-lang/rust#67454
1 parent 2bd73fa commit ef7b1b4

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

collector/benchmarks/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ programs.
6767
- **coercions**: Contains a static array with 65,536 string literals, which
6868
caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
6969
the past.
70+
- **combine**: Contains a small `combine`-based parser that caused a [large
71+
performance regression](https://github.com/rust-lang/rust/issues/67454) in
72+
the past.
7073
- **ctfe-stress-4**: A stress test for compile-time function evaluation.
7174
- **deeply-nested**: A small program that caused [exponential
7275
behavior](https://github.com/rust-lang/rust/issues/38528) in the past.
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
**/*.rs.bk

collector/benchmarks/combine/Cargo.lock

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "combine-bench"
3+
license = "MIT"
4+
version = "0.1.0"
5+
authors = ["Sebastian Dröge <sebastian@centricular.com>", "François Laignel <fengalin@free.fr>"]
6+
edition = "2018"
7+
8+
[dependencies]
9+
combine = "3.8"
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use combine::byte::hex_digit;
2+
use combine::{choice, token};
3+
use combine::{ParseError, Parser, RangeStream};
4+
5+
pub fn parse<'a, I: 'a>() -> impl Parser<Input = I, Output = u8>
6+
where
7+
I: RangeStream<Item = u8, Range = &'a [u8]>,
8+
I::Error: ParseError<I::Item, I::Range, I::Position>,
9+
{
10+
choice!(
11+
token(b'A').map(|_| 1),
12+
token(b'B').map(|_| 2),
13+
token(b'C').map(|_| 3),
14+
token(b'D').map(|_| 4),
15+
token(b'E').map(|_| 5),
16+
token(b'F').map(|_| 6),
17+
token(b'G').map(|_| 7),
18+
token(b'H').map(|_| 8),
19+
token(b'I').map(|_| 9),
20+
token(b'J').map(|_| 10),
21+
token(b'K').map(|_| 11),
22+
token(b'L').map(|_| 12),
23+
token(b'M').map(|_| 13),
24+
token(b'N').map(|_| 14),
25+
token(b'O').map(|_| 15),
26+
token(b'P').map(|_| 16),
27+
token(b'Q').map(|_| 17),
28+
token(b'R').map(|_| 18),
29+
(hex_digit(), hex_digit()).map(|(u, l)| {
30+
let val = (u << 4) | l;
31+
val
32+
})
33+
)
34+
.message("while parsing")
35+
}

0 commit comments

Comments
 (0)