From: "Jürgen Strobel" Date: 2006-08-29T11:35:30+09:00 Subject: Re: For performance, write it in C --T4sUOijqQbZv57TR Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Aug 26, 2006 at 11:23:02PM +0900, Jordan Callicoat wrote: > J=FCrgen Strobel wrote: > Ok, fair enough. I made the assumption that the testing was done on a=20 > terminal emulator since the perl execution time was given as 12 minutes= =20 > and the faster version of the ruby algorithm writing to a file rather=20 > than stdout took only 17 seconds, whereas it took 26 minutes writing to= =20 > stdout--I assumed that the perl version would be comparable with file=20 > writing rather than writing to standard out. I used xterm. >=20 > > All you did benchmark was that your terminal emulator (or whereever > > your stdout goes to) is slow. >=20 > Yes! That's exactly what I was trying to do! I was trying to show that=20 > writing to stdout (assuming a comparable context, like an xterm) is the= =20 > bottle-neck of the ruby version here. Writing to a file was about 90=20 > times faster. Like I said, I wasn't denying that C is faster; my point=20 > was this: the C version may only take 5 seconds to write to a *file*,=20 > but ruby only takes 17 seconds; and for me, as I'm sure for others, 12=20 > seconds is not worth the effort of writing it in C. So the 12 minutes to= =20 > 5 seconds comparison was flawed -- 17 seconds to 5 seconds is more=20 > accurate. Usually you don't benchmark with external arbitrary bottlenecks enabled. The point is, *your* xterm may be of very different speed than mine. Generic terminal emulators are not a comparable context at all, not without benchmarking them themselves, which is not the point of this exercise. I should have emphasized *your terminal emulator*. We are comparing ruby vs. C, so it makes sense to assume a fast and uniform output mechanism which doesn't get in our way. It is standard practice to write to stdout, but redirect it to /dev/null or files if writeing larger quantities in benchmarks. To get real numbers, your C version took 0.010s CPU time, and your ruby one took 0.202s. A difference of roughly 2000% may well be important to several applications. Sometimes it may be completely irrelevant, for instance if CPU time is dwarfed by I/O. -J=FCrgen --=20 The box said it requires Windows 95 or better so I installed Linux --T4sUOijqQbZv57TR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iQEVAwUBRPOn6vy64gyiEfXtAQLkBQf/aOk+mKWF1rUQebZ5tpdN0Et5+82CCe+/ o+bkEWHVz1M7u9iCGjbVj2xMV9JDSh9ZnoeZumoYoE7pYdmHmpP3Ng8gikcTlLmS 5SJzF3ZOcWjSpFhRZRCUTWKzdYi5ovZA2hD2K7Izr7NVXcmMNXY8vs3r5LejGqBy Bsj47+KColDxe1KeRk4h8iIPpCg1oYP/T4pK6t9/a8LE0cL9uIU0DGt3Tkmhqfzt ub9mlGmwWf6j1S8BYwW47k1j63Z+CX79nITBE7JWs9obs7gNKGxS6/aaOAAezR7Q AANwHh0neTDN1bpQX5kjWvETmZcN/VG2s4jj2ibTGJ7+jqYLkwP09A== =1xhZ -----END PGP SIGNATURE----- --T4sUOijqQbZv57TR--