summaryrefslogtreecommitdiffstats
path: root/benches
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-06-28 14:14:07 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-06-28 14:14:07 -0700
commit80c1bc0f339189a49a90562047f5d9def65d3f4a (patch)
tree1ba8608b24f35326ed585002d48e5d3610332d86 /benches
parentda6c82fa307278cdeb2c15f9a31282fb80ac768f (diff)
Benchmark & improve md parsing
Diffstat (limited to 'benches')
-rw-r--r--benches/html_parsing.rs (renamed from benches/parsing.rs)4
-rw-r--r--benches/md_parsing.rs32
2 files changed, 34 insertions, 2 deletions
diff --git a/benches/parsing.rs b/benches/html_parsing.rs
index ae6ccf0..07c1420 100644
--- a/benches/parsing.rs
+++ b/benches/html_parsing.rs
@@ -19,7 +19,7 @@ use std::time::Duration;
///
/// Still, I could try creating a regex that captures the url encoded SE url and question id and
/// multiline regex the entire HTML document. It might be faster than the scraper library?
-fn bench_parsers(c: &mut Criterion) {
+fn bench_html_parsers(c: &mut Criterion) {
let limit: u16 = 10;
let mut sites = HashMap::new();
sites.insert(
@@ -70,5 +70,5 @@ fn bench_parsers(c: &mut Criterion) {
group.finish();
}
-criterion_group!(benches, bench_parsers);
+criterion_group!(benches, bench_html_parsers);
criterion_main!(benches);
diff --git a/benches/md_parsing.rs b/benches/md_parsing.rs
new file mode 100644
index 0000000..eae9988
--- /dev/null
+++ b/benches/md_parsing.rs
@@ -0,0 +1,32 @@
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use so::tui::markdown::parse;
+
+const MD: &str = r####"
+## project
+
+Here's some `inline code`. It should escape `*asterisks*`.
+It should also respect
+
+ indented code blocks
+
+and
+```python
+code fences
+```
+Obviously.
+
+### but also
+I'm on a Mac running OS&nbsp;X&nbsp;v10.6 (Snow&nbsp;Leopard). I have Mercurial 1.1 installed.
+
+After I hit **[Esc]** to exit insert mode I can't figure out how to save and quit. Hitting **[Ctrl]** + **[C]** shows me instructions that say typing "quit<enter>" will write and quit, but it doesn't seem to work.
+
+
+"####;
+
+// TODO bench preprocess as well, separately
+pub fn md_benchmark(c: &mut Criterion) {
+ c.bench_function("markdown::parse", |b| b.iter(|| parse(black_box(MD))));
+}
+
+criterion_group!(benches, md_benchmark);
+criterion_main!(benches);