[Melbourne-pm] and the winner is C! (so far anyway, no big surprise)

Sam Watkins sam at nipl.net
Fri May 21 01:54:37 PDT 2010


On Fri, May 21, 2010 at 06:38:24PM +1000, Toby Corkindale wrote:
> On 21/05/10 18:23, Sam Watkins wrote:
> > Here's the leaderboard of CSV readers in various languages, compared  
> to C,
> > for a 100,000 line CSV file:
> >
> > 	C           1.00
> > 	brace       1.16
> > 	perl XS    11.33
> > 	(bad) go   17.50
> > 	scala      19.32
> > 	perl       62.51
>
>
> Umm, I think you're comparing the wrong results there; for the 100k  
> file, Perl only takes 1.1 seconds for me.
> (However the C version only takes 0.11 seconds on that file!)

Yes, those figures were relative to the C version, that's why C is 1.00.

1.1 / 0.11 = 10 means perl XS gets a score of about 10 on your machine
- it's 10 times slower than C.

By the way, I compiled it something like this:

	gcc -pedantic -std=gnu99 -Wall -Wextra -O2 -o read-c read.c

> For the "big" 10m row file, the C version takes 7.90 seconds on my  
> testbed, which definitely takes it into the lead, by far! (The next  
> fastest contender is over a minute, and perl takes 108 seconds)

Yes, the C version is about 10 times faster than the next fastest
(excluding brace, which is essentially just C anyway).

> I'm going to modify the tests and give them another shot once I've  
> eliminated the buffer flushing..

ok, cool.  When I just commented out the printf I'm not sure how much other
stuff the C compiler might have been discarding... "hey, he's not using this,
no need to calculate it!"


Sam


More information about the Melbourne-pm mailing list