Another C++ entry

Dave Smith dave at thesmithfam.org
Wed Mar 22 21:55:50 MST 2006


Sasha Pachev wrote:
> Anybody wants to shake his C/C++ muscle?

My muscles are pretty puny, but here's my attempt in C. It runs in 1.9 
seconds on my 2.4GHz RedHat box on the kjv100 file. I believe this is 
one of the fastest times. The algorithm uses a constant-time hash table 
of my own design, which lives in a very sparse array of 1 million 
(mostly empty) entries. It runs with just 99 collisions in the hash's 
key space. Interestingly, it turns out that I/O is not the big part of 
the time (0.2 seconds to load both files). The fun part is that I didn't 
do any string copies from the original data. That was kind of groovy. 
The con is that it uses a TON of memory. It loads both files completely 
into memory before working on the data. I could have worked around this, 
to allow arbitrarily large files, but I've spent too much time now. :)

Bryan, could you run this code on your benchmark box? I'm curious how it 
compares with the others.

Enjoy!

--Dave


P.S. To whomever it was that was whining about not having incentive: 
Don't be a wimp. The code is the incentive.

P.P.S. I am NOT looking for employment. I already have the best job in 
the world.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: word-count.c
Url: http://plug.org/pipermail/plug/attachments/20060322/9da2e990/attachment.c 


More information about the PLUG mailing list