in reply to Re: Re: Thousands separator - this is getting annoying
in thread Thousands separator - this is getting annoying
Results:use Benchmark; my $foo = join ',', ('bar') x 100; timethese(-10, { 's' => sub { (my $bar = $foo) =~ s/,//g }, 'tr' => sub { (my $bar = $foo) =~ tr/,//d }, });
tr is 10 times faster here! A definite improvement.Benchmark: running s, tr, each for at least 10 CPU seconds... s: 10 wallclock secs (10.00 usr + 0.00 sys = 10.00 CPU) @ 10 +150.70/s (n=101507) tr: 10 wallclock secs (10.01 usr + 0.00 sys = 10.01 CPU) @ 10 +9117.38/s (n=1092265)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Thousands separator - this is getting annoying
by tye (Sage) on Jan 17, 2001 at 03:58 UTC | |
by mrmick (Curate) on Jan 17, 2001 at 18:46 UTC |