-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
33c9da0
commit f253f68
Showing
5 changed files
with
204 additions
and
0 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,17 @@ | ||
use std::collections::HashMap; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use simpleinterpolation::Interpolation; | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
let interp = Interpolation::new("{interp}").unwrap(); | ||
let mut data = HashMap::new(); | ||
data.insert( | ||
"interp".into(), | ||
include_str!("very_long_uninterpolated.txt").into(), | ||
); | ||
c.bench_function("no interpolation", |b| b.iter(|| interp.render(&data))); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use std::collections::HashMap; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use simpleinterpolation::Interpolation; | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
let interp = Interpolation::new(include_str!("very_long_uninterpolated.txt")).unwrap(); | ||
let empty_hashmap = HashMap::new(); | ||
c.bench_function("no interpolation", |b| { | ||
b.iter(|| interp.render(&empty_hashmap)) | ||
}); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this is a very long test string, but it doesn't do any interpolation by default. We don't do interpolation here because we want to see how it performs in odd cases like this one, or ones where we're only interpolating a tiny bit of text, like for example a user's name. |