D
Derek Chesterfield
I know 1.9.0 is still a work in progress, but I was expecting to see
some benefit from YARV already. However, this simple script showing a
typical bit of logfile processing takes over 70% LONGER under Ruby 1.9
$ ruby -v
$ ruby logreport2.rb
$ ruby19 -v
$ ruby19 logreport2.rb
some benefit from YARV already. However, this simple script showing a
typical bit of logfile processing takes over 70% LONGER under Ruby 1.9
$ cat logreport2.rb
require 'benchmark'
include Benchmark
logfile=<<END_OF_STRING
23:59:16 drop 10.14.241.252 >eth2c1 rule: 1015; rule_uid:
{6AADF426-0D0C-4C20-A027-06A6DC8C6CE2}; src: 172.25.20.79; dst:
10.14.65.137; proto: tcp; product: VPN-1 & FireWall-1; service:
lotus; s_port: 57150;
23:59:15 drop 10.14.241.251 >eth2c1 rule: 1015; rule_uid:
{6AADF426-0D0C-4C20-A027-06A6DC8C6CE2}; src: 172.25.40.88; dst:
10.14.65.37; proto: tcp; product: VPN-1 & FireWall-1; service:
TCP1801; s_port: 24511;
23:59:15 drop 10.14.241.251 >eth1c0 rule: 1015; rule_uid:
{6AADF426-0D0C-4C20-A027-06A6DC8C6CE2}; src: 10.14.163.59; dst:
10.24.0.2; proto: udp; product: VPN-1 & FireWall-1; service: domain-
udp; s_port: udp1025-1027;
END_OF_STRING
bm(12) do |test|
test.report('Simple:') do
500000.times do
src=Hash.new(0)
logfile.each_line do |line|
if (m=line.match /src: (.*?);/)
src[m[1]]= src[m[1]] +1
end
end
end
end
end
$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]
$ ruby logreport2.rb
user system total real
Simple: 7.960000 0.000000 7.960000 ( 7.965567)
$ ruby19 -v
ruby 1.9.0 (2007-12-25 revision 14709) [i686-darwin9.1.0]
$ ruby19 logreport2.rb