Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

UnicodeWidthChar should inline an ascii fast path #1

Open
@pnkfelix

Description

@pnkfelix

(imported from improperly closed bugrust-lang/rust#20658 )

So, the good news is that this cargo package is beating the deprecated stdlib code on my machine.

The bad news is that it is still slower than what the original issue author expects to see.

(Though I also don't think the original issue author's code is conformant with what the docs here say thefn width method should do onchar.)

Anyway, here is a port of the benchmark provided by the original author, adapted to also test this cargo package. It is followed with the benchmark results on my machine.

#![feature(test, unicode)]externcrate test;externcrate unicode_width;use test::{Bencher};use unicode_width::UnicodeWidthChar;constSTRING:&'staticstr ="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";#[bench]fnstdlib(b:&mutBencher){    b.iter(||{for cinSTRING.chars(){            test::black_box(c.width(false));}});}#[bench]fncargo(b:&mutBencher){    b.iter(||{for cinSTRING.chars(){            test::black_box(UnicodeWidthChar::width(c));}});}#[bench]fnsimple(b:&mutBencher){    b.iter(||{for cinSTRING.chars(){if(casu32) <127{if(casu32) >31{                    test::black_box(Some(1));}else{                    test::black_box(None::<usize>);}}else{                test::black_box(c.width(false));}}});}

03-03-58 char_fast_path/char_fast_path (git:fsk-sized-bounded-iter) % rustc --versionrustc 1.0.0-nightly (1284be404 2015-04-18) (built 2015-04-17)03-04-12 char_fast_path/char_fast_path (git:fsk-sized-bounded-iter) % cargo bench     Running target/release/char_fast_path-935b3c19b07d9282running 3 teststest cargo  ... bench:      3197 ns/iter (+/- 401)test simple ... bench:      1465 ns/iter (+/- 500)test stdlib ... bench:      3427 ns/iter (+/- 571)test result: ok. 0 passed; 0 failed; 0 ignored; 3 measured03-04-21 char_fast_path/char_fast_path (git:fsk-sized-bounded-iter) %

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp