Subject: | Performance improvement Suggestions |
Date: | Mon, 14 Oct 2013 13:35:34 +0800 |
To: | bug-Lingua-Han-PinYin [...] rt.cpan.org |
From: | Weeky <free.mr.zhou [...] gmail.com> |
please see the below, why not use tr/// instead of s/// ? if replacement
occupied, Accelerate the 4*5=20 times.
791 41µs2 22µs
# spent 15.7s (14.7+913ms) within Lingua::Han::PinYin::_fix_val which was
called 242014 times, avg 65µs/call: # 242014 times (14.7s+913ms) by
Lingua::Han::PinYin::han2pinyin at line
55<Lingua-Han-PinYin-pm-51-line.html#55>,
avg 65µs/call
sub _fix_val {
# spent 20µs making 1 call to
Encode::utf8::decode_xs<Encode-pm-29-line.html#Encode__utf8__decode_xs>#
spent 2µs making 1 call to
Encode::Encoding::renewed <Encode-Encoding-pm-35-line.html#38>
80242014 115ms1 1µs my ( $self, $value ) = @_;
# spent 1µs making 1 call to
Encode::utf8::encode_xs<Encode-pm-29-line.html#Encode__utf8__encode_xs>
81 82 24201469.5ms 221µs if ($self->{unicode}) {
# spent 20µs making 1 call to
Encode::utf8::decode_xs<Encode-pm-29-line.html#Encode__utf8__decode_xs>#
spent 1µs making 1 call to
Encode::Encoding::renewed <Encode-Encoding-pm-35-line.html#38>
83 return $value;84 11µs }
# spent 1µs making 1 call to
Encode::utf8::encode_xs<Encode-pm-29-line.html#Encode__utf8__encode_xs>
85 86 1108µs 221µs # convert into ascii
# spent 20µs making 1 call to
Encode::utf8::decode_xs<Encode-pm-29-line.html#Encode__utf8__decode_xs>#
spent 2µs making 1 call to
Encode::Encoding::renewed <Encode-Encoding-pm-35-line.html#38>
87 242014925ms 24201475.1ms $value =~ s/ū/u/g and $value .= '1';
# spent 75.1ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 310ns/call
88 242014698ms 24201427.1ms $value =~ s/ī/i/g and $value .= '1';
# spent 27.1ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 112ns/call
89 242014674ms 24201431.5ms $value =~ s/ō/o/g and $value .= '1';
# spent 31.5ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 130ns/call
90 242014636ms 24201430.1ms $value =~ s/ā/a/g and $value .= '1';
# spent 30.1ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 124ns/call
91 242014685ms 24201531.5ms $value =~ s/ē/e/g and $value .= '1';
# spent 31.5ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 130ns/call # spent 2µs making 1 call to
Encode::utf8::encode_xs<Encode-pm-29-line.html#Encode__utf8__encode_xs>
92 93 242014783ms 24201673.8ms $value =~ s/í/i/g and $value .= '2';
# spent 73.7ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 305ns/call # spent 20µs making 1 call to
Encode::utf8::decode_xs<Encode-pm-29-line.html#Encode__utf8__decode_xs>#
spent 2µs making 1 call to
Encode::Encoding::renewed <Encode-Encoding-pm-35-line.html#38>
94 242014662ms 24201456.0ms $value =~ s/é/e/g and $value .= '2';
# spent 56.0ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 232ns/call
95 242014735ms 24201433.0ms $value =~ s/ú/u/g and $value .= '2';
# spent 33.0ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 137ns/call
96 2420141.15s 24201438.4ms $value =~ s/ó/o/g and $value .= '2';
# spent 38.4ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 159ns/call
97 242014709ms 24201537.8ms $value =~ s/á/a/g and $value .= '2';
# spent 37.8ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 156ns/call # spent 2µs making 1 call to
Encode::utf8::encode_xs<Encode-pm-29-line.html#Encode__utf8__encode_xs>
98 99 242014630ms 24201632.0ms $value =~ s/ě/e/g and $value .= '3';
# spent 32.0ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 132ns/call # spent 20µs making 1 call to
Encode::utf8::decode_xs<Encode-pm-29-line.html#Encode__utf8__decode_xs>#
spent 2µs making 1 call to
Encode::Encoding::renewed <Encode-Encoding-pm-35-line.html#38>
100 242014654ms 24201429.7ms $value =~ s/ǎ/a/g and $value .= '3';
# spent 29.7ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 123ns/call
101 242014624ms 24201429.2ms $value =~ s/ǒ/o/g and $value .= '3';
# spent 29.2ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 121ns/call
102 242014632ms 24201434.0ms $value =~ s/ǔ/u/g and $value .= '3';
# spent 34.0ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 141ns/call
103 242014595ms 24201532.4ms $value =~ s/ǐ/i/g and $value .= '3';
# spent 32.4ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 134ns/call # spent 2µs making 1 call to
Encode::utf8::encode_xs<Encode-pm-29-line.html#Encode__utf8__encode_xs>
104 105 242014693ms 24201654.6ms $value =~ s/ò/o/g and $value .= '4';
# spent 54.5ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 225ns/call # spent 20µs making 1 call to
Encode::utf8::decode_xs<Encode-pm-29-line.html#Encode__utf8__decode_xs>#
spent 2µs making 1 call to
Encode::Encoding::renewed <Encode-Encoding-pm-35-line.html#38>
106 242014725ms 24201453.3ms $value =~ s/à/a/g and $value .= '4';
# spent 53.3ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 220ns/call
107 242014728ms 24201433.4ms $value =~ s/è/e/g and $value .= '4';
# spent 33.4ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 138ns/call
108 242014617ms 24201433.5ms $value =~ s/ù/u/g and $value .= '4';
# spent 33.5ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 139ns/call
109 242014701ms 24201549.6ms $value =~ s/ì/i/g and $value .= '4';
# spent 49.6ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 205ns/call # spent 2µs making 1 call to
Encode::utf8::encode_xs<Encode-pm-29-line.html#Encode__utf8__encode_xs>
110 111 242014745ms 24201696.5ms $value =~ s/\d//g unless $self->{tone};
# spent 96.5ms making 242014 calls to
Lingua::Han::PinYin::CORE:subst<Lingua-Han-PinYin-pm-51-line.html#Lingua__Han__PinYin__CORE_subst>,
avg 399ns/call # spent 20µs making 1 call to
Encode::utf8::decode_xs<Encode-pm-29-line.html#Encode__utf8__decode_xs>#
spent 2µs making 1 call to
Encode::Encoding::renewed <Encode-Encoding-pm-35-line.html#38>
112 242014966ms return $value;
Message body is not shown because it is too large.