summaryrefslogtreecommitdiff
path: root/benches
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-01-13 19:49:52 +0100
committerLaurenz <laurmaedje@gmail.com>2022-01-13 19:55:32 +0100
commit4abdafcd158ab15d9d2ae18553067578ae559d33 (patch)
treeb1081ad25b7984bd8504008cd971bc2ce20224b3 /benches
parentb3062ee8804580f65d5232846f1ccd199b2ff1c7 (diff)
Faster byte/utf-16 offset conversions
Diffstat (limited to 'benches')
-rw-r--r--benches/oneshot.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/benches/oneshot.rs b/benches/oneshot.rs
index c088a93c..4f71b944 100644
--- a/benches/oneshot.rs
+++ b/benches/oneshot.rs
@@ -66,6 +66,26 @@ fn bench_layout(iai: &mut Iai) {
iai.run(|| tree.layout(&mut ctx));
}
+fn bench_highlight(iai: &mut Iai) {
+ let (ctx, id) = context();
+ let source = ctx.sources.get(id);
+ iai.run(|| source.highlight(0 .. source.len_bytes(), |_, _| {}));
+}
+
+fn bench_byte_to_utf16(iai: &mut Iai) {
+ let (ctx, id) = context();
+ let source = ctx.sources.get(id);
+ let mut ranges = vec![];
+ source.highlight(0 .. source.len_bytes(), |range, _| ranges.push(range));
+ iai.run(|| {
+ ranges
+ .iter()
+ .map(|range| source.byte_to_utf16(range.start)
+ .. source.byte_to_utf16(range.end))
+ .collect::<Vec<_>>()
+ });
+}
+
main!(
bench_decode,
bench_scan,
@@ -73,5 +93,7 @@ main!(
bench_parse,
bench_edit,
bench_eval,
- bench_layout
+ bench_layout,
+ bench_highlight,
+ bench_byte_to_utf16,
);