-
Notifications
You must be signed in to change notification settings - Fork 44
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
15 changed files
with
248 additions
and
103 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,26 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
pub fn benchmark(c: &mut Criterion) { | ||
let words_per_line = [ | ||
5, 10, 15, 5, 5, 10, 5, 5, 5, 10, // 10 lines | ||
10, 10, 5, 5, 5, 5, 15, 10, 5, 5, // 20 lines | ||
10, 5, 5, 5, 15, 10, 10, 5, 5, 5, // 30 lines | ||
15, 5, 5, 10, 5, 5, 5, 15, 5, 10, // 40 lines | ||
5, 15, 5, 5, 15, 5, 10, 10, 5, 5, // 50 lines | ||
]; | ||
let mut text = String::new(); | ||
for (line_no, word_count) in words_per_line.iter().enumerate() { | ||
text.push_str("\t\t\t"); | ||
text.push_str(&lipsum::lipsum_words_from_seed(*word_count, line_no as u64)); | ||
text.push('\n'); | ||
} | ||
text.push_str("\n\n\n\n"); | ||
assert_eq!(text.len(), 2800); // The size for reference. | ||
|
||
c.bench_function("display_width", |b| { | ||
b.iter(|| textwrap::core::display_width(&text, 2)) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, 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
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
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
Oops, something went wrong.