Skip to content

Commit 2934fd0

Browse files
committed
Time how long it takes to render HTML
1 parent d213784 commit 2934fd0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/librustdoc/core.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ where
280280
(lint_opts, lint_caps)
281281
}
282282

283-
pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOptions) {
283+
pub fn run_core(
284+
options: RustdocOptions,
285+
) -> (clean::Crate, RenderInfo, RenderOptions, Lrc<Session>) {
284286
// Parse, resolve, and typecheck the given crate.
285287

286288
let RustdocOptions {
@@ -457,7 +459,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
457459

458460
let mut global_ctxt = abort_on_err(queries.global_ctxt(), sess).take();
459461

460-
sess.time("run_global_ctxt", || {
462+
let (krate, render_info, opts) = sess.time("run_global_ctxt", || {
461463
global_ctxt.enter(|tcx| {
462464
run_global_ctxt(
463465
tcx,
@@ -468,7 +470,8 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
468470
output_format,
469471
)
470472
})
471-
})
473+
});
474+
(krate, render_info, opts, Lrc::clone(sess))
472475
})
473476
})
474477
}

src/librustdoc/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ fn main_options(options: config::Options) -> MainResult {
501501
let crate_name = options.crate_name.clone();
502502
let crate_version = options.crate_version.clone();
503503
let output_format = options.output_format;
504-
let (mut krate, renderinfo, renderopts) = core::run_core(options);
504+
let (mut krate, renderinfo, renderopts, sess) = core::run_core(options);
505505

506506
info!("finished with rustc");
507507

@@ -524,11 +524,11 @@ fn main_options(options: config::Options) -> MainResult {
524524
let (error_format, edition, debugging_options) = diag_opts;
525525
let diag = core::new_handler(error_format, None, &debugging_options);
526526
match output_format {
527-
None | Some(config::OutputFormat::Html) => {
527+
None | Some(config::OutputFormat::Html) => sess.time("render html", || {
528528
run_renderer::<html::render::Context>(krate, renderopts, renderinfo, &diag, edition)
529-
}
530-
Some(config::OutputFormat::Json) => {
529+
}),
530+
Some(config::OutputFormat::Json) => sess.time("render json", || {
531531
run_renderer::<json::JsonRenderer>(krate, renderopts, renderinfo, &diag, edition)
532-
}
532+
}),
533533
}
534534
}

0 commit comments

Comments
 (0)