Permalink
Browse files

Scope stack matching benchmark

  • Loading branch information...
1 parent a0de35d commit 38ff0c988073abbcc9ad3158acb0e4a335448468 @trishume committed Jun 30, 2016
Showing with 13 additions and 1 deletion.
  1. +13 −1 benches/highlighting.rs
@@ -4,9 +4,10 @@ extern crate test;
extern crate syntect;
use test::Bencher;
-use syntect::parsing::{SyntaxSet, SyntaxDefinition};
+use syntect::parsing::{SyntaxSet, SyntaxDefinition, ScopeStack};
use syntect::highlighting::{ThemeSet, Theme};
use syntect::easy::HighlightLines;
+use std::str::FromStr;
use std::fs::File;
use std::io::Read;
@@ -63,3 +64,14 @@ fn bench_highlighting_rustc(b: &mut Bencher) {
fn bench_highlighting_scope(b: &mut Bencher) {
highlight_file(b, "src/parsing/scope.rs");
}
+
+#[bench]
+fn bench_stack_matching(b: &mut Bencher) {
+ let s = "source.js meta.group.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.object-literal.js meta.block.js meta.function-call.method.js meta.group.js variable.other.readwrite.js";
+ let stack = ScopeStack::from_str(s).unwrap();
+ let selector = ScopeStack::from_str("source meta.function-call.method").unwrap();
+ b.iter(|| {
+ let res = selector.does_match(stack.as_slice());
+ test::black_box(res);
+ });
+}

0 comments on commit 38ff0c9

Please sign in to comment.