Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6edf05b

Browse files
Add #[bench] for librustdoc's syntax highlighter
1 parent a2db928 commit 6edf05b

File tree

2 files changed

+15
-1
lines changed
  • src

2 files changed

+15
-1
lines changed

‎src/bootstrap/src/core/builder/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ impl<'a> Builder<'a> {
11451145
test::RunMakeCargo,
11461146
),
11471147
Kind::Miri => describe!(test::Crate),
1148-
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
1148+
Kind::Bench => describe!(test::Crate, test::CrateLibrustc, test::CrateRustdoc),
11491149
Kind::Doc => describe!(
11501150
doc::UnstableBook,
11511151
doc::UnstableBookGen,

‎src/librustdoc/html/highlight/tests.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use expect_test::expect_file;
22
use rustc_data_structures::fx::FxIndexMap;
33
use rustc_span::create_default_session_globals_then;
4+
use test::Bencher;
45

56
use super::{DecorationInfo, write_code};
67

@@ -81,3 +82,16 @@ let a = 4;";
8182
expect_file!["fixtures/decorations.html"].assert_eq(&html);
8283
});
8384
}
85+
86+
#[bench]
87+
fn bench_html_highlighting(b: &mut Bencher) {
88+
let src = include_str!("../../../../compiler/rustc_ast/src/visit.rs");
89+
90+
create_default_session_globals_then(|| {
91+
b.iter(|| {
92+
let mut out = String::new();
93+
write_code(&mut out, src, None, None, None);
94+
out
95+
});
96+
});
97+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /