This repository has been archived by the owner on Feb 12, 2018. It is now read-only.
forked from trishume/syntect
-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
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,34 @@ | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
extern crate syntect; | ||
use test::Bencher; | ||
|
||
use syntect::package_set::PackageSet; | ||
use syntect::parser::*; | ||
use syntect::theme::highlighter::*; | ||
use syntect::theme::style::*; | ||
use std::fs::File; | ||
use std::io::Read; | ||
|
||
#[bench] | ||
fn bench_highlighting(b: &mut Bencher) { | ||
let ps = PackageSet::load_from_folder("testdata/Packages").unwrap(); | ||
let highlighter = Highlighter::new(PackageSet::get_theme("testdata/spacegray/base16-ocean.\ | ||
dark.tmTheme") | ||
.unwrap()); | ||
let mut f = File::open("testdata/highlight_test.erb").unwrap(); | ||
let mut s = String::new(); | ||
f.read_to_string(&mut s).unwrap(); | ||
let syntax = ps.find_syntax_by_extension("erb").unwrap(); | ||
b.iter(|| { | ||
let mut state = ParseState::new(syntax); | ||
let mut highlight_state = HighlightState::new(&highlighter, state.scope_stack.clone()); | ||
for line in s.lines() { | ||
let ops = state.parse_line(&line); | ||
let iter = HighlightIterator::new(&mut highlight_state, &ops[..], &line, &highlighter); | ||
let regions: Vec<(Style, &str)> = iter.collect(); | ||
test::black_box(®ions); | ||
} | ||
}); | ||
} |
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,15 @@ | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
extern crate syntect; | ||
use test::Bencher; | ||
|
||
use syntect::package_set::PackageSet; | ||
|
||
#[bench] | ||
fn bench_load_syntaxes(b: &mut Bencher) { | ||
b.iter(|| { | ||
let mut ps = PackageSet::new(); | ||
ps.load_syntaxes("testdata/Packages", false).unwrap(); | ||
}); | ||
} |
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