🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #47275

Re: Exemplary ANSI C programming, an example

#47275
From: DaveK
Date: Mon, 16 Dec 2002 17:25
53 lines
3994 bytes
"Thomas J. Boschloo" <nospam@hccnet.nl.invalid> wrote in message
news:3DFB07E9.5D961C57@hccnet.nl.invalid...
> Since 99.8% of the world's professional programmers can't code, I
> thought I would show them. Check out this word frequency counting
> utility at <http://home.hccnet.nl/t.j.boschloo/wordcnt> and flame me
> into the pits of hell.
>

  Hi Thomas, hope you don't mind but I'll try and be constructive instead!

---snip---
Some of the design principles I used were:

  a.. no memory allocation
---snip---
  j.. no gulping up system resources in a multi-tasking environment so the
program could be run from a script on a (usenet-) server
---snip---

  These two design principles don't really go together.  In your program (32
bit version) you have a huge static array; that memory space needs to be
reserved (if not committed) by the virtual memory system of whatever the
program runs on each time the program starts up.  It would be less load and
more mt-friendly to only allocate a small buffer to start with and only grow
it if necessary.

  Also, your use of the hash value in your program is rather unconventional
to say the least.  Hashes are most efficient when the hashvalue itself (or
some derivative of it; often just the n least significant bits) is used to
directly index the array or table being searched.  Doing a linear search,
albeit with only a single comparison of a long (rather than the entire
string) at each entry, loses almost all the efficiency you can gain from
using a good hash.  If you're processing a million words, and there are ten
thousand unique words in the set, looping through a large subset of those
words each of a million times will be horribly slow.

  Here's a really good site I stumbled across a while ago when I was
researching hashes myself, you might find it interesting.

http://burtleburtle.net/bob/hash/index.html

      DaveK
--
moderator of
alt.talk.rec.soc.biz.news.comp.humanities.meow.misc.moderated.meow
Burn your ID card!  http://www.optional-identity.org.uk/
Help support the campaign, copy this into your .sig!
Proud Member of the Exclusive "I have been plonked by Davee because he
thinks I'm interesting" List Member #<insert number here>
Master of Many Meowing Minions
Holder of the exhalted PF Chang's Crab Wonton Award for kook spankage above
and beyond the call of hilarity.
PGP Key-ID: 0x0FB504D1 Fingerprint 04B7 2E8C 0245 680E  6484 C441 CEC7 D2BD
Technical Details
Message-ID: <%0oL9.1742$zF4.69397@newsfep1-gui.server.ntli.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.fan.cult-dead-cow.mbox.zip!archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!newspeer1-gui.server.ntli.net!ntli.net!newsfep1-gui.server.ntli.net.POSTED!53ab2750!not-for-mail
References: <3DFB07E9.5D961C57@hccnet.nl.invalid>

Show Full Headers
Complete Article Headers
Message-ID: <%0oL9.1742$zF4.69397@newsfep1-gui.server.ntli.net>
Subject: Re: Exemplary ANSI C programming, an example
Date: Mon, 16 Dec 2002 17:25:58 -0000
From: "DaveK" <DaveK@dontspamme.petitmorte.noireallydontlikethepinkstuff.net>
References: <3DFB07E9.5D961C57@hccnet.nl.invalid>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.fan.cult-dead-cow.mbox.zip!archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!newspeer1-gui.server.ntli.net!ntli.net!newsfep1-gui.server.ntli.net.POSTED!53ab2750!not-for-mail
Newsgroups: comp.lang.c,alt.fan.cult-dead-cow,alt.privacy.anon-server
Lines: 57
Organization: Lumber Cartel (tinlc) Members #2234-2237 (owing to browser refresh)
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
X-Inktomi-Trace: pc1-cmbg1-3-cust106.cmbg.cable.ntl.com 1040059578 19091 62.253.132.106 (16 Dec 2002 17:26:18 GMT)
NNTP-Posting-Host: 80.1.224.5
X-Complaints-To: abuse@ntlworld.com
X-Trace: newsfep1-gui.server.ntli.net 1040059579 80.1.224.5 (Mon, 16 Dec 2002 17:26:19 GMT)
NNTP-Posting-Date: Mon, 16 Dec 2002 17:26:19 GMT