in reply to Re: Re: Re: Re: string manipulation
in thread string manipulation
#!/usr/local/bin/perl -w use strict; use Benchmark; my $count =500000; ## Method number one sub One { my $data = 'for bar baz'; my($outstring); ($outstring = $data) =~ tr/-/_/; } ## Method number two sub Two { my $data = 'for bar baz'; my($outstring) = $data; $outstring =~ s/-/_/g; } ## We'll test each one, with simple labels timethese ( $count, {'Method One TR' => '&One', 'Method Two S' => '&Two', } ); exit;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Re: Re: string manipulation
by extremely (Priest) on Mar 30, 2001 at 04:23 UTC |