Skip Menu |

This queue is for tickets about the Lingua-Han-PinYin CPAN distribution.

Report information
The Basics
Id: 89444
Status: open
Priority: 0/
Queue: Lingua-Han-PinYin

People
Owner: Nobody in particular
Requestors: free.mr.zhou [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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.

would you mind attach it? It is very hard to find the changes from the text. Thanks On Mon Oct 14 01:36:12 2013, free.mr.zhou@gmail.com wrote: Show quoted text
> 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;
Subject: Re: [rt.cpan.org #89444] Performance improvement Suggestions
Date: Wed, 16 Oct 2013 12:15:24 +0800
To: bug-Lingua-Han-PinYin [...] rt.cpan.org
From: Weeky <free.mr.zhou [...] gmail.com>
Hi, here is my solution: $value =~ s/ū/u/g and $value .= '1'; $value =~ s/ī/i/g and $value .= '1'; $value =~ s/ō/o/g and $value .= '1'; $value =~ s/ā/a/g and $value .= '1'; $value =~ s/ē/e/g and $value .= '1'; which should be replace by: $value =~ s/ū/u1/g; $value =~ s/ī/i1/g; $value =~ s/ō/o1/g; $value =~ s/ā/a1/g; $value =~ s/ē/e1/g'; or $value =~ tr/ūī/ui/g; like this. And you can try use tr/// instead of all the s///. thanks. 2013/10/14 Fayland Lin via RT <bug-Lingua-Han-PinYin@rt.cpan.org> Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=89444 > > > would you mind attach it? It is very hard to find the changes from the > text. > > Thanks > > On Mon Oct 14 01:36:12 2013, free.mr.zhou@gmail.com wrote:
> > 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;
> > > >
Hi. it's a bit different. for example. ài, with my code it's ai4. but with s/à/a4/, it's a4i. let me know if I am wrong. Thanks
Subject: Re: [rt.cpan.org #89444] Performance improvement Suggestions
Date: Thu, 24 Oct 2013 18:47:04 +0800
To: bug-Lingua-Han-PinYin [...] rt.cpan.org
From: Weeky <free.mr.zhou [...] gmail.com>
Oh, i am sorry. $value =~ tr/ūē/ue/g and $value .= '1'; this will be ok. 2013/10/16 Fayland Lin via RT <bug-Lingua-Han-PinYin@rt.cpan.org> Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=89444 > > > Hi. it's a bit different. > > for example. > > ài, with my code it's ai4. but with s/à/a4/, it's a4i. > > let me know if I am wrong. > > Thanks >
looks like I need put use utf8; for a test script like #!/usr/bin/perl use strict; use warnings; use utf8; my $pinyin = 'hēshui'; $pinyin =~ tr/ūīōāē/uioae/ and $pinyin .= '1'; print $pinyin . "\n"; 1; but it is still not working in PinYin.pm even I put use utf8. can you fork the repos on github https://github.com/fayland/perl-lingua-han and make changes then make sure prove -l t/ working? Thanks