Righto!
New numbers:
user system total real
park: 4.875000 0.070312 4.945312 ( 4.994253)
original: 11.375000 0.117188 11.492188 ( 11.549160)
and this is interesting:
#!/usr/bin/perl
use Benchmark;
open(F,"<keys") || die $!;
timethese (1, {
perl => q{
while(<F>) {
chomp;
tr/=/,/;
%h = split(',');
}
}
}
);
Benchmark: timing 1 iterations of perl...
perl: 6 wallclock secs ( 6.52 usr + 0.10 sys = 6.62 CPU)
btw, ruby's benchmarking module is spoiling me :-)
-joe
> -----Original Message-----
> From: dave / thomases.com [mailto:dave / thomases.com]
> Sent: Friday, December 15, 2000 9:53 PM
> To: ruby-talk ML
> Subject: [ruby-talk:7408] Re: Ruby performance question
>
>
> "Joseph McDonald" <joe / vpop.net> writes:
>
> > def park_readfile
> > h = Hash.new
> > file = File.new("keys")
> > while line = file.gets
> > h = Hash[*line.chomp!.tr!('=', ',').split(',')]
> > # do stuff here...
> > h.clear
> > end
> > end
>
> You could speed this up a bit more... you don't need the h.clear
> anymore, as you're creating the hash fresh each time around.
>
> Dave
>