One of the few disappointing benchmarks. The intent is to be an example of
simple line-oriented reading/processing, not to be the fastest example of a
wc-like program:
$ cat wc.rb
nwords, nbytes,nlines = 0,0,0
ARGF.each do |line|
words = line.split
nwords += words.length
nbytes += line.length
nlines += 1
end
printf "%7d %7d %7d total\n", nlines, nwords, nbytes;
__END__
$ ruby -v
ruby 1.8.4 (2006-02-01) [i686-linux]
$ ./yarv -v
ruby 1.9.0 (2005-11-18) [i686-linux]
YARVCore 0.3.3 (rev: 366) [opts: ]
$ time ruby wc.rb ../../Tdata/large.txt
208048 1675832 11021496 total
real 0m9.293s
user 0m9.090s
sys 0m0.130s
$ time ./yarv wc.rb ../../Tdata/large.txt
208048 1675832 11021496 total
real 0m13.671s
user 0m13.350s
sys 0m0.230s
So, in this application yarv is a little slower. Further investigation
(commenting out lines in the loop) show that yarv is a little slower on
both reading and splitting. Too bad, as those are pretty common operations.
On the other hand, yarv is young yet.