mirror of
https://github.com/typst/typst
synced 2025-07-27 22:37:54 +08:00
More detailed introspector timings
This commit is contained in:
parent
187dcc4d3a
commit
af173acd59
@ -13,7 +13,7 @@ use typst_library::foundations::{Content, StyleChain};
|
|||||||
use typst_library::introspection::{
|
use typst_library::introspection::{
|
||||||
Introspector, IntrospectorBuilder, Locator, ManualPageCounter, SplitLocator, TagElem,
|
Introspector, IntrospectorBuilder, Locator, ManualPageCounter, SplitLocator, TagElem,
|
||||||
};
|
};
|
||||||
use typst_library::layout::{FrameItem, Page, PagedDocument, Point, Transform};
|
use typst_library::layout::{FrameItem, Page, PagedDocument, Point, Position, Transform};
|
||||||
use typst_library::model::DocumentInfo;
|
use typst_library::model::DocumentInfo;
|
||||||
use typst_library::routines::{Arenas, Pair, RealizationKind, Routines};
|
use typst_library::routines::{Arenas, Pair, RealizationKind, Routines};
|
||||||
use typst_library::World;
|
use typst_library::World;
|
||||||
@ -171,15 +171,25 @@ fn introspect_pages(pages: &[Page]) -> Introspector {
|
|||||||
// Discover all elements.
|
// Discover all elements.
|
||||||
let mut elems = Vec::new();
|
let mut elems = Vec::new();
|
||||||
for (i, page) in pages.iter().enumerate() {
|
for (i, page) in pages.iter().enumerate() {
|
||||||
|
handle_page(&mut builder, &mut elems, page, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.finalize(elems)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[typst_macros::time(name = "handle page")]
|
||||||
|
fn handle_page(
|
||||||
|
builder: &mut IntrospectorBuilder,
|
||||||
|
elems: &mut Vec<(Content, Position)>,
|
||||||
|
page: &Page,
|
||||||
|
i: usize,
|
||||||
|
) {
|
||||||
builder.page_numberings.push(page.numbering.clone());
|
builder.page_numberings.push(page.numbering.clone());
|
||||||
builder.page_supplements.push(page.supplement.clone());
|
builder.page_supplements.push(page.supplement.clone());
|
||||||
builder.discover_in_frame(
|
builder.discover_in_frame(
|
||||||
&mut elems,
|
elems,
|
||||||
&page.frame,
|
&page.frame,
|
||||||
NonZeroUsize::new(1 + i).unwrap(),
|
NonZeroUsize::new(1 + i).unwrap(),
|
||||||
Transform::identity(),
|
Transform::identity(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.finalize(elems)
|
|
||||||
}
|
|
||||||
|
@ -435,6 +435,7 @@ impl IntrospectorBuilder {
|
|||||||
|
|
||||||
/// Build a complete introspector with all acceleration structures from a
|
/// Build a complete introspector with all acceleration structures from a
|
||||||
/// list of top-level pairs.
|
/// list of top-level pairs.
|
||||||
|
#[typst_macros::time]
|
||||||
pub fn finalize(mut self, root: Vec<Pair>) -> Introspector {
|
pub fn finalize(mut self, root: Vec<Pair>) -> Introspector {
|
||||||
self.locations.reserve(self.seen.len());
|
self.locations.reserve(self.seen.len());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user