1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
use base_db::{util::LineCol, Owner, Workspace};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use distro::Language;
use lsp_types::{ClientCapabilities, Position, Url};
use parser::{parse_latex, SyntaxConfig};
const CODE: &str = include_str!("../../../texlab.tex");
fn criterion_benchmark(c: &mut Criterion) {
let config = SyntaxConfig::default();
c.bench_function("LaTeX/Parser", |b| {
b.iter(|| parse_latex(black_box(CODE), &config));
});
c.bench_function("LaTeX/Completion/Command", |b| {
let uri = Url::parse("http://example.com/texlab.tex").unwrap();
let text = CODE.to_string();
let mut workspace = Workspace::default();
workspace.open(
uri.clone(),
text,
Language::Tex,
Owner::Client,
LineCol { line: 0, col: 0 },
);
let client_capabilities = ClientCapabilities::default();
b.iter(|| {
texlab::features::completion::complete(
&workspace,
&uri,
Position::new(0, 1),
&client_capabilities,
None,
)
});
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
|