From: "José A. S. Alegria" Date: 2003-04-23T06:08:20+09:00 Subject: Performance test: 1.8.0p2 versus 1.6.8 This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C3091B.9E68EF70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all! I've just run an experiment to see how Ruby 1.8.0p2 and Ruby = 1.6.8 compared to Python 2.2.2 on Mandrake Linux 9.0. For this I used a = 1GB Dell workstation with dual Xeon CPUs and dual SCSI 18GB disks. I = tried to test basic sequential text file I/O, string.split(";") and = hashing. The test CSV file was reasonably large (around 400MBytes and = 3.5 million lines). The timmings I've got are: Ruby 1.6.8 on Linux =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Test 1 --> elapsed time to read the full file, line by line, and = counting the number of lines =3D=3D> 23 seconds Test 2 --> the same as above but now including for each line read fields =3D line.split(";", -1) n_fields +=3D fields.length =3D=3D> 57 seconds (delta=3D34 seconds for the extra = string.split stuff) Test 3 --> the same as Test 2 but now adding an hash table = (table=3DHash.new(0)) to count all occurrences of different values for = fields[5] table[fields[5]] +=3D 1 =3D=3D> 65 seconds (delta=3D8 seconds for the extra = hashing stuff) =20 Ruby 1.8.0p2 also on Linux =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Test 1 --> 7 seconds (3 times faster than version 1.6.8 !!!) Test 2 --> 83 seconds (delta=3D76 secs --> quite slower than version = 1.6.8!!!) Test 3 --> 91 seconds (delta=3D8 secs --> same speed as version 1.6.8) First conclusion: 1.8.0p2 is much faster than version 1.6.8 for basic = sequential text I/O but string operations like str.split(";", -1) seem = to be 50% slower! Any reason for this? Python 2.2.2 also on Linux =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Test 1 --> 8 secs (aprox. the same speed as Ruby 1.8.0p2) Test 2 --> 62 secs (delta=3D54 secs, a bit faster than Ruby 1.6.8) Test 3 --> 73 secs (delta=3D9 secs --> a tiny bit slower than Ruby = 1.8.0p2 or 1.6.8) So, at least for these very very basic operations Ruby compares well = with Python. Any idea why Ruby 1.8.0p2 is slower than version 1.6.8 for = such a basic operation like string.split(";", -1) ? Regards, J. Alegria BTW: While Python on Windows Xp (on the same machine) is almost as fast = as on Linux the same doesnt't seem true for Ruby. The Windows version is = slower than the linux one! ------=_NextPart_000_0005_01C3091B.9E68EF70 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi all! I've just run an experiment to see how = Ruby=20 1.8.0p2 and Ruby 1.6.8 compared to Python 2.2.2 on Mandrake Linux 9.0. = For this=20 I used a 1GB Dell workstation with dual Xeon CPUs and dual SCSI 18GB = disks. I=20 tried to test basic sequential text file I/O, string.split(";") and = hashing. The=20 test CSV file was reasonably large (around 400MBytes and 3.5 million=20 lines).
 
The timmings I've got are:
 
Ruby 1.6.8 on Linux
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 
Test 1 --> elapsed time to read the full = file, line by=20 line, and counting the number of lines =3D=3D> 23 = seconds
Test 2 --> the same as above but now = including for each=20 line read
          =        =20         fields =3D = line.split(";",=20 -1)
          =             &= nbsp;  =20 n_fields +=3D fields.length
          =      =20 =3D=3D> 57 seconds (delta=3D34 seconds for the extra string.split=20 stuff)
Test 3 --> the same as Test 2 but now adding = an hash=20 table (table=3DHash.new(0)) to count all occurrences of different values = for=20 fields[5]
          =             &= nbsp;   table[fields[5]]=20 +=3D 1
          =      =20 =3D=3D> 65 seconds (delta=3D8 seconds for the extra hashing=20 stuff)
        
Ruby 1.8.0p2 also on Linux
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D
 
Test 1 -->   7 seconds  (3 = times faster=20 than version 1.6.8 !!!)
Test 2 --> 83 seconds (delta=3D76 secs --> = quite=20 slower than version 1.6.8!!!)
Test 3 --> 91 seconds (delta=3D8 secs --> = same speed=20 as version 1.6.8)
 
First conclusion: 1.8.0p2 is much faster than = version=20 1.6.8 for basic sequential text I/O but string operations like = str.split(";",=20 -1) seem to be 50% slower! Any reason for this?
 
Python 2.2.2 also on Linux
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 
Test 1 --> 8 secs (aprox. the same speed as = Ruby=20 1.8.0p2)
Test 2 --> 62 secs (delta=3D54 secs, a bit = faster=20 than Ruby 1.6.8)
Test 3 --> 73 secs (delta=3D9 secs --> a = tiny bit=20 slower than Ruby 1.8.0p2 or 1.6.8)
 
So, at least for these very very basic = operations Ruby=20 compares well with Python. Any idea why Ruby 1.8.0p2 is slower than = version=20 1.6.8 for such a basic operation like string.split(";", -1) = ?
 
Regards,
 
J. Alegria
 
BTW: While Python on Windows Xp (on the same = machine) is=20 almost as fast as on Linux the same doesnt't seem true for Ruby. = The=20 Windows version is slower than the linux one!
 
------=_NextPart_000_0005_01C3091B.9E68EF70--