-
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
15 changed files
with
342 additions
and
82 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,98 @@ | ||
#![feature(await_macro, async_await)] | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use futures::executor::block_on; | ||
use lsp_types::*; | ||
use texlab::scenario::Scenario; | ||
|
||
fn initialize(name: &'static str) -> Scenario { | ||
let scenario = block_on(Scenario::new("completion/bench")); | ||
block_on(scenario.open(name)); | ||
scenario | ||
} | ||
|
||
fn run(scenario: &Scenario, name: &str, position: Position, has_items: bool) { | ||
let uri = scenario.uri(name); | ||
let params = CompletionParams { | ||
text_document: TextDocumentIdentifier::new(uri), | ||
position, | ||
context: None, | ||
}; | ||
let items = block_on(scenario.server.completion(params)).unwrap(); | ||
assert_eq!(items.items.len() > 0, has_items); | ||
} | ||
|
||
fn criterion_benchmark(criterion: &mut Criterion) { | ||
let scenario = initialize("foo.tex"); | ||
criterion.bench_function("LaTeX word", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.tex", Position::new(5, 0), false); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.tex"); | ||
criterion.bench_function("LaTeX command", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.tex", Position::new(6, 1), true); | ||
}) | ||
}); | ||
|
||
let scenario = initialize("foo.tex"); | ||
criterion.bench_function("LaTeX argument symbol", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.tex", Position::new(7, 8), true); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.tex"); | ||
criterion.bench_function("LaTeX environment", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.tex", Position::new(8, 7), true); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.tex"); | ||
criterion.bench_function("LaTeX class import", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.tex", Position::new(9, 15), true); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.tex"); | ||
criterion.bench_function("LaTeX package import", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.tex", Position::new(10, 12), true); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.bib"); | ||
criterion.bench_function("BibTeX type", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.bib", Position::new(0, 1), true); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.bib"); | ||
criterion.bench_function("BibTeX type", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.bib", Position::new(0, 1), true); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.bib"); | ||
criterion.bench_function("BibTeX field", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.bib", Position::new(3, 5), true); | ||
}); | ||
}); | ||
|
||
let scenario = initialize("foo.bib"); | ||
criterion.bench_function("BibTeX command", move |b| { | ||
b.iter(|| { | ||
run(&scenario, "foo.bib", Position::new(7, 14), true); | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
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 @@ | ||
@ | ||
|
||
@article{foo, | ||
bar = baz, | ||
} | ||
|
||
@article{foo, | ||
bar = {\baz}, | ||
} |
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,13 @@ | ||
\documentclass{article} | ||
|
||
\usepackage{amsmath} | ||
|
||
\begin{document} | ||
|
||
\ | ||
\mathbb{} | ||
\begin{} | ||
\documentclass{} | ||
\usepackage{} | ||
|
||
\end{document} |
Oops, something went wrong.