-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #35 - behnam:dev, r=mbrubeck
Fix a bug in reorder_line() and improve benchmarks Summary of changes: * Fix bug in reorder_line() where optimized branch returned the full text (instead of line text), after (supposedly) reorder. * Improve benchmarks logic to measure `reorder_line()` in isolation, and for full text of the test. * Add new `basic` benchmarks to be able to measure perf for small, common text strings. * Move `serde_test` to `dev-dependencies`, as it's only used in `test` profile. * Bump version to `0.3.2`. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/unicode-bidi/35) <!-- Reviewable:end -->
- Loading branch information
Showing
11 changed files
with
173 additions
and
74 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,69 @@ | ||
// Copyright 2014 The html5ever Project Developers. See the | ||
// COPYRIGHT file at the top-level directory of this distribution. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![cfg(all(test, feature = "unstable"))] | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
extern crate unicode_bidi; | ||
|
||
use test::Bencher; | ||
|
||
use unicode_bidi::BidiInfo; | ||
|
||
|
||
const LTR_TEXTS: &[&str] = &[ | ||
"abc\ndef\nghi", | ||
"abc 123\ndef 456\nghi 789", | ||
]; | ||
|
||
const BIDI_TEXTS: &[&str] = &[ | ||
"ابجد\nهوز\nحتی", | ||
"ابجد ۱۲۳\nهوز ۴۵۶\nحتی ۷۸۹", | ||
]; | ||
|
||
|
||
fn bench_bidi_info_new(b: &mut Bencher, texts: &[&str]) { | ||
for text in texts { | ||
b.iter(|| { BidiInfo::new(text, None); }); | ||
} | ||
} | ||
|
||
fn bench_reorder_line(b: &mut Bencher, texts: &[&str]) { | ||
for text in texts { | ||
let bidi_info = BidiInfo::new(text, None); | ||
b.iter( | ||
|| for para in &bidi_info.paragraphs { | ||
let line = para.range.clone(); | ||
bidi_info.reorder_line(para, line); | ||
} | ||
); | ||
} | ||
} | ||
|
||
|
||
#[bench] | ||
fn bench_1_bidi_info_new_for_ltr_texts(b: &mut Bencher) { | ||
bench_bidi_info_new(b, LTR_TEXTS); | ||
} | ||
|
||
#[bench] | ||
fn bench_2_bidi_info_new_for_bidi_texts(b: &mut Bencher) { | ||
bench_bidi_info_new(b, BIDI_TEXTS); | ||
} | ||
|
||
#[bench] | ||
fn bench_3_reorder_line_for_ltr_texts(b: &mut Bencher) { | ||
bench_reorder_line(b, LTR_TEXTS); | ||
} | ||
|
||
#[bench] | ||
fn bench_4_reorder_line_for_bidi_texts(b: &mut Bencher) { | ||
bench_reorder_line(b, BIDI_TEXTS); | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.