in reply to Re^2: The indisputable speed of tr///
in thread The indisputable speed of tr///
I wonder ... if all you were doing was some transliteration why would you bother with the lines at all? Read and process say 64 KB at once. As I said, not sure this is doable in your case.
Second ... why would you spend time "figuring out reasonable character classes? If you have the mapping hash, just build the tr/// out of it. I just tried to benchmark the difference between tr/a-z/A-Z/ and tr/abcdef...xyz/ABCDEF...ZYX/ and the later actually came out a tiny little bit faster. So you could either have the tr/// generated from the hash and copy the result into the script or use string eval to define a subroutine to do the transliteration. my $sub = eval 'sub { my $x = shift(); $x=~ tr/' . join('', keys %h) . '/' . join('', values %h) . '/; return $x}'; or something. If the loop is simple enough you could eval the whole loop so that you do not waste time by the subroutine call for each line. Or am I missing something?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: The indisputable speed of tr///
by radiantmatrix (Parson) on Jun 27, 2006 at 14:32 UTC | |
by ikegami (Patriarch) on Jun 27, 2006 at 16:59 UTC | |
by runrig (Abbot) on Jun 27, 2006 at 17:27 UTC | |
by radiantmatrix (Parson) on Jun 28, 2006 at 14:04 UTC | |
by Jenda (Abbot) on Jun 27, 2006 at 17:30 UTC | |
by Hue-Bond (Priest) on Jun 27, 2006 at 18:07 UTC | |
by duff (Parson) on Jun 27, 2006 at 18:32 UTC |