Add initial support for doing benchmarking and some starting info on how to build the benchmark stuff with poppler debug info

This commit is contained in:
itsjunetime
2024-06-03 22:16:05 -06:00
parent 017596a8b0
commit 7e2d0d3bea
13 changed files with 531 additions and 49 deletions
Generated
+335 -26
View File
@@ -29,12 +29,33 @@ dependencies = [
"zerocopy",
]
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "anes"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anstyle"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
[[package]]
name = "autocfg"
version = "1.3.0"
@@ -74,6 +95,12 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "bumpalo"
version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "bytemuck"
version = "1.16.0"
@@ -116,6 +143,12 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "cast"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "castaway"
version = "0.2.2"
@@ -147,6 +180,58 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "ciborium"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
dependencies = [
"ciborium-io",
"ciborium-ll",
"serde",
]
[[package]]
name = "ciborium-io"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
[[package]]
name = "ciborium-ll"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
dependencies = [
"ciborium-io",
"half",
]
[[package]]
name = "clap"
version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
version = "4.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
dependencies = [
"anstyle",
"clap_lex",
]
[[package]]
name = "clap_lex"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
[[package]]
name = "compact_str"
version = "0.7.1"
@@ -169,6 +254,42 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "criterion"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
dependencies = [
"anes",
"cast",
"ciborium",
"clap",
"criterion-plot",
"is-terminal",
"itertools 0.10.5",
"num-traits",
"once_cell",
"oorandom",
"plotters",
"rayon",
"regex",
"serde",
"serde_derive",
"serde_json",
"tinytemplate",
"walkdir",
]
[[package]]
name = "criterion-plot"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
dependencies = [
"cast",
"itertools 0.10.5",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.13"
@@ -229,6 +350,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "dyn-clone"
version = "1.0.17"
@@ -436,7 +563,7 @@ version = "0.19.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70025dbfa1275cf7d0531c3317ba6270dae15d87e63342229d638246ff45202e"
dependencies = [
"heck 0.5.0",
"heck",
"proc-macro-crate",
"proc-macro2",
"quote",
@@ -464,6 +591,16 @@ dependencies = [
"system-deps",
]
[[package]]
name = "half"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
dependencies = [
"cfg-if",
"crunchy",
]
[[package]]
name = "hashbrown"
version = "0.14.5"
@@ -474,12 +611,6 @@ dependencies = [
"allocator-api2",
]
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "heck"
version = "0.5.0"
@@ -543,6 +674,26 @@ dependencies = [
"libc",
]
[[package]]
name = "is-terminal"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.12.1"
@@ -567,6 +718,15 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "js-sys"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "kqueue"
version = "1.0.8"
@@ -705,6 +865,12 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "oorandom"
version = "11.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
[[package]]
name = "parking_lot"
version = "0.12.3"
@@ -752,6 +918,34 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "plotters"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3"
dependencies = [
"num-traits",
"plotters-backend",
"plotters-svg",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "plotters-backend"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7"
[[package]]
name = "plotters-svg"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705"
dependencies = [
"plotters-backend",
]
[[package]]
name = "png"
version = "0.17.13"
@@ -809,9 +1003,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.84"
version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6"
checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23"
dependencies = [
"unicode-ident",
]
@@ -927,6 +1121,35 @@ dependencies = [
"bitflags 2.5.0",
]
[[package]]
name = "regex"
version = "1.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
[[package]]
name = "rustc-demangle"
version = "0.1.24"
@@ -993,6 +1216,17 @@ dependencies = [
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.6"
@@ -1080,11 +1314,11 @@ dependencies = [
[[package]]
name = "strum_macros"
version = "0.26.2"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946"
checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87"
dependencies = [
"heck 0.4.1",
"heck",
"proc-macro2",
"quote",
"rustversion",
@@ -1109,7 +1343,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
dependencies = [
"cfg-expr",
"heck 0.5.0",
"heck",
"pkg-config",
"toml",
"version-compare",
@@ -1126,6 +1360,7 @@ name = "tdf"
version = "0.1.0"
dependencies = [
"cairo-rs",
"criterion",
"crossterm",
"futures-util",
"glib",
@@ -1159,10 +1394,20 @@ dependencies = [
]
[[package]]
name = "tokio"
version = "1.37.0"
name = "tinytemplate"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "tokio"
version = "1.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
dependencies = [
"backtrace",
"num_cpus",
@@ -1172,9 +1417,9 @@ dependencies = [
[[package]]
name = "tokio-macros"
version = "2.2.0"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
dependencies = [
"proc-macro2",
"quote",
@@ -1183,14 +1428,14 @@ dependencies = [
[[package]]
name = "toml"
version = "0.8.13"
version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba"
checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.22.13",
"toml_edit 0.22.14",
]
[[package]]
@@ -1215,15 +1460,15 @@ dependencies = [
[[package]]
name = "toml_edit"
version = "0.22.13"
version = "0.22.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c"
checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.6.9",
"winnow 0.6.11",
]
[[package]]
@@ -1287,6 +1532,70 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "web-sys"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "winapi"
version = "0.3.9"
@@ -1468,9 +1777,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.6.9"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6"
checksum = "56c52728401e1dc672a56e81e593e912aa54c78f40246869f78359a2bf24d29d"
dependencies = [
"memchr",
]
+21 -2
View File
@@ -3,10 +3,18 @@ name = "tdf"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
default-run = "tdf"
[[bin]]
name = "tdf"
# lib only exists for benching
[lib]
name = "tdf"
[dependencies]
poppler-rs = { version = "0.23.0", features = ["v21_5"] }
cairo-rs = { version = "0.19.4", features = ["png"] }
poppler-rs = { version = "0.23.0", default-features = false, features = ["v23_7"] }
cairo-rs = { version = "0.19.4", default-features = false, features = ["png"] }
# we're using this branch because it has significant performance fixes that I'm waiting on responses from the upstream devs to get upstreamed. See https://github.com/ratatui-org/ratatui/issues/1116
ratatui = { git = "https://github.com/itsjunetime/ratatui.git" }
# ratatui = { path = "./ratatui" }
@@ -24,3 +32,14 @@ itertools = "*"
[profile.production]
inherits = "release"
lto = "fat"
[dev-dependencies]
criterion = "0.5.1"
[[bench]]
name = "rendering"
harness = false
[[bin]]
name = "for_profiling"
path = "./benches/for_profiling.rs"
+1 -1
View File
@@ -22,7 +22,7 @@ If it turns out that you're missing one of these, it will fail to compile and te
2. Clone the repo and `cd` into it
3. Run `cargo build --release`
Alternatively, if you'd like to squeeze the most performance out of this tool, you'll want to run `bash ./build_most_optimized.sh` and pull the resulting binary from `./target/$target/tdf`.
Alternatively, if you'd like to squeeze the most performance out of this tool, you'll want to run `bash ./scripts/build_most_optimized.sh` and pull the resulting binary from `./target/$target/tdf`.
## Why in the world would you use this?
Binary file not shown.
Binary file not shown.
+10
View File
@@ -0,0 +1,10 @@
mod utils;
#[tokio::main]
async fn main() {
let file = std::env::args()
.nth(1)
.expect("Please enter a file to profile");
utils::render_doc(file).await;
}
+30
View File
@@ -0,0 +1,30 @@
mod utils;
use utils::render_doc;
use criterion::{criterion_group, criterion_main, Criterion};
fn render_dict(c: &mut Criterion) {
c.bench_function(
"example dictionary",
|b| b.iter(||
tokio::runtime::Runtime::new()
.unwrap()
.block_on(render_doc("./benches/example_dictionary.pdf"))
)
);
}
fn render_example(c: &mut Criterion) {
c.bench_function(
"adobe-provided sample",
|b| b.iter(||
tokio::runtime::Runtime::new()
.unwrap()
.block_on(render_doc("./benches/adobe_example.pdf"))
)
);
}
criterion_group!(benches, render_dict, render_example);
criterion_main!(benches);
+94
View File
@@ -0,0 +1,94 @@
use std::{hint::black_box, path::Path};
use crossterm::terminal::WindowSize;
use ratatui::layout::Rect;
use ratatui_image::picker::{Picker, ProtocolType};
use tdf::{converter::{run_conversion_loop, ConvertedPage, ConverterMsg}, renderer::{fill_default, start_rendering, RenderError, RenderInfo, RenderNotif}};
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
pub async fn render_doc(path: impl AsRef<Path>) {
let pathbuf = path.as_ref().canonicalize().unwrap();
let str_path = format!("file://{}", pathbuf.into_os_string().to_string_lossy());
let (to_render_tx, from_main_rx) = unbounded_channel();
let (to_main_tx, mut from_render_rx) = unbounded_channel();
let font_size = (8, 14);
let (columns, rows) = (60, 180);
let size = WindowSize {
columns,
rows,
height: rows * font_size.1,
width: columns * font_size.0
};
std::thread::spawn(move || {
start_rendering(str_path, to_main_tx, from_main_rx, size)
});
let (mut to_converter_tx, from_main_rx) = unbounded_channel();
let (to_main_tx, mut from_converter_rx) = unbounded_channel();
let mut picker = Picker::new(font_size);
picker.protocol_type = ProtocolType::Kitty;
tokio::spawn(run_conversion_loop(to_main_tx, from_main_rx, picker));
let mut pages: Vec<Option<ConvertedPage>> = Vec::new();
fn handle_renderer_msg(
msg: Result<RenderInfo, RenderError>,
pages: &mut Vec<Option<ConvertedPage>>,
to_converter_tx: &mut UnboundedSender<tdf::converter::ConverterMsg>,
) {
match msg {
Ok(RenderInfo::NumPages(num)) => {
fill_default(pages, num);
to_converter_tx.send(ConverterMsg::NumPages(num)).unwrap();
},
Ok(RenderInfo::Page(info)) => to_converter_tx.send(ConverterMsg::AddImg(info)).unwrap(),
Err(e) => panic!("Got error from renderer: {e:?}")
}
}
fn handle_converter_msg(
msg: Result<ConvertedPage, RenderError>,
pages: &mut [Option<ConvertedPage>],
to_converter_tx: &mut UnboundedSender<ConverterMsg>
) {
let page = msg.expect("Got error from converter");
let num = page.num;
pages[num] = Some(page);
let num_got = pages.iter()
.filter(|p| p.is_some())
.count();
// we have to tell it to jump to a certain page so that it will actually render it (since
// it only renders fanning out from the page that we currently have selected)
to_converter_tx.send(ConverterMsg::GoToPage(num_got)).unwrap();
}
let main_area = Rect {
x: 0,
y: 0,
width: columns - 2,
height: rows - 6
};
to_render_tx.send(RenderNotif::Area(main_area)).unwrap();
while pages.is_empty() || pages.iter().any(|p| p.is_none()) {
tokio::select! {
Some(renderer_msg) = from_render_rx.recv() => {
handle_renderer_msg(renderer_msg, &mut pages, &mut to_converter_tx);
},
Some(converter_msg) = from_converter_rx.recv() => {
handle_converter_msg(converter_msg, &mut pages, &mut to_converter_tx);
}
}
}
black_box(pages);
}
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# 1. Pull the git source of poppler
# 2. cd poppler
# 3. git checkout poppler-23.07.0
# 4. mkdir build
# 5. cd build
# 6. cmake .. -DENABLE_GPGME=OFF -DENABLE_QT5=OFF -DENABLE_QT6=OFF -DENABLE_BOOST=OFF -DBUILD_SHARED_LIBS=OFF
# 7. cmake --build . --parallel $(nproc)
env SYSTEM_DEPS_POPPLER_GLIB_LINK=static \
SYSTEM_DEPS_POPPLER_GLIB_NO_PKG_CONFIG=1 \
SYSTEM_DEPS_POPPLER_GLIB_SEARCH_NATIVE=/path/to/poppler/build/glib \
SYSTEM_DEPS_POPPLER_GLIB_LIB=poppler-glib \
cargo perf --bin for_profiling --
+6
View File
@@ -0,0 +1,6 @@
#![feature(if_let_guard)]
pub mod renderer;
pub mod converter;
pub mod tui;
pub mod skip;
+1 -2
View File
@@ -41,8 +41,7 @@ impl std::error::Error for BadTermSizeStdin {}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut args = std::env::args().skip(1);
let file = args.next().ok_or("Program requires a file to process")?;
let file = std::env::args().nth(1).ok_or("Program requires a file to process")?;
let path = PathBuf::from_str(&file)?.canonicalize()?;
let (watch_tx, render_rx) = tokio::sync::mpsc::unbounded_channel();
+3 -1
View File
@@ -314,13 +314,14 @@ fn render_single_page(
// that as the background color, then paint, then render.
ctx.set_source_rgba(1.0, 1.0, 1.0, 1.0);
ctx.set_antialias(Antialias::Best);
ctx.set_antialias(Antialias::None);
ctx.paint()
.map_err(|e| format!("Couldn't paint Context: {e}"))?;
page.render(&ctx);
let num_results = result_rects.len();
if !result_rects.is_empty() {
let mut highlight_color = Color::new();
highlight_color.set_red((u16::MAX / 5) * 4);
highlight_color.set_green((u16::MAX / 5) * 4);
@@ -341,6 +342,7 @@ fn render_single_page(
&mut highlight_color
);
}
}
ctx.scale(1. / scale_factor, 1. / scale_factor);