-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
9,291 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mod benchmarks; | ||
|
||
use criterion::Criterion; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
benchmarks::open_latex::benches().await; | ||
Criterion::default().configure_from_args().final_summary(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod open_latex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use criterion::Criterion; | ||
use std::{env, time::Duration}; | ||
use texlab::{ | ||
protocol::{Options, Uri}, | ||
syntax::latex, | ||
tex::Distribution, | ||
}; | ||
use tokio::fs; | ||
|
||
async fn criterion_benchmark(criterion: &mut Criterion) { | ||
let distro = Distribution::detect().await; | ||
distro | ||
.load() | ||
.await | ||
.expect("failed to load TeX distribution"); | ||
let resolver = distro.resolver().await; | ||
let path = resolver | ||
.files_by_name | ||
.get("symbols.tex") | ||
.expect("unable to retrieve symbols.tex"); | ||
|
||
let text = fs::read_to_string(&path).await.unwrap(); | ||
let uri = Uri::from_file_path(&path).unwrap(); | ||
let options = Options::default(); | ||
let cwd = env::current_dir().unwrap(); | ||
let params = latex::OpenParams { | ||
text: &text, | ||
uri: &uri, | ||
resolver: &resolver, | ||
options: &options, | ||
cwd: &cwd, | ||
}; | ||
|
||
criterion.bench_function("symbols.tex", |b| b.iter(|| latex::open(params))); | ||
} | ||
|
||
pub async fn benches() { | ||
let mut criterion = Criterion::default() | ||
.configure_from_args() | ||
.sample_size(15) | ||
.measurement_time(Duration::from_secs(30)); | ||
criterion_benchmark(&mut criterion).await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.