about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYotam Ofek <yotam.ofek@gmail.com>2025-09-30 00:14:03 +0300
committerYotam Ofek <yotam.ofek@gmail.com>2025-09-30 21:13:45 +0300
commit6edf05b740070429e57ec18e5c027167dbb17ab4 (patch)
tree8015a87185b590d12b8cd5d989f386e7b8e6a2e4 /src
parenta2db9280539229a3b8a084a09886670a57bc7e9c (diff)
downloadrust-6edf05b740070429e57ec18e5c027167dbb17ab4.tar.gz
rust-6edf05b740070429e57ec18e5c027167dbb17ab4.zip
Add `#[bench]` for librustdoc's syntax highlighter
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/core/builder/mod.rs2
-rw-r--r--src/librustdoc/html/highlight/tests.rs14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs
index 006dea4b98d..fc06db8f80b 100644
--- a/src/bootstrap/src/core/builder/mod.rs
+++ b/src/bootstrap/src/core/builder/mod.rs
@@ -1145,7 +1145,7 @@ impl<'a> Builder<'a> {
                 test::RunMakeCargo,
             ),
             Kind::Miri => describe!(test::Crate),
-            Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
+            Kind::Bench => describe!(test::Crate, test::CrateLibrustc, test::CrateRustdoc),
             Kind::Doc => describe!(
                 doc::UnstableBook,
                 doc::UnstableBookGen,
diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs
index 2603e887bea..4d1bee9b3a1 100644
--- a/src/librustdoc/html/highlight/tests.rs
+++ b/src/librustdoc/html/highlight/tests.rs
@@ -1,6 +1,7 @@
 use expect_test::expect_file;
 use rustc_data_structures::fx::FxIndexMap;
 use rustc_span::create_default_session_globals_then;
+use test::Bencher;
 
 use super::{DecorationInfo, write_code};
 
@@ -81,3 +82,16 @@ let a = 4;";
         expect_file!["fixtures/decorations.html"].assert_eq(&html);
     });
 }
+
+#[bench]
+fn bench_html_highlighting(b: &mut Bencher) {
+    let src = include_str!("../../../../compiler/rustc_ast/src/visit.rs");
+
+    create_default_session_globals_then(|| {
+        b.iter(|| {
+            let mut out = String::new();
+            write_code(&mut out, src, None, None, None);
+            out
+        });
+    });
+}