add benchmarks ; add explicit #[inline] annotations

This diff adds benchmarks to get more info regarding Issue #1.

It appears that the remaining difference between the "simple"
case and the "cargo" case is the result of a difference in
performance between using `match` and `if` for tight loops.

I suspect it's because of the way that match arms get reordered:
if I manually reorder the "if" statement, I can reproduce the
match performance.

Also added a couple #[inline] annotations in tables.rs, though
the difference in performance in my measurements is negligible.

Bumped version number to 0.1.1.
This commit is contained in:
kwantam
2015-04-18 23:46:57 -04:00
parent 1d27b56ea3
commit cbad406d03
8 changed files with 169 additions and 67 deletions
+2
View File
@@ -206,6 +206,7 @@ def emit_charwidth_module(f, width_table):
#[cfg(feature = "no_std")]
use core::result::Result::{Ok, Err};
#[inline]
fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {
#[cfg(feature = "no_std")]
use core::cmp::Ordering::{Equal, Less, Greater};
@@ -226,6 +227,7 @@ def emit_charwidth_module(f, width_table):
""")
f.write("""
#[inline]
pub fn width(c: char, is_cjk: bool) -> Option<usize> {
match c as usize {
_c @ 0 => Some(0), // null is zero width