comp.lang.ada
 help / color / mirror / Atom feed
From: "Martin Dowie" <martin.dowie@baesystems.com>
Subject: Re: reading a text file into a string
Date: Thu, 29 Jul 2004 08:25:57 +0100
Date: 2004-07-29T08:25:57+01:00	[thread overview]
Message-ID: <4108a544$1_1@baen1673807.greenlnk.net> (raw)
In-Reply-To: qoSdne3LhqX115XcRVn-qA@megapath.net

Randy Brukardt wrote:
> Anyway, my opinion these days is that spending a lot of effort making
> something run 2% faster is wasted effort. You're always better off
> changing to a different way of solving the problem. The most recent
> instance was in my web log analyzer. It was running too slow on the
> AdaIC site's logs, and I wasted a lot of time trying to improve it.
> But replacing the binary lookups (log N, N being around 200,000) by a
> hashed lookup (very similar to switching from Sorted _Sets to
> Hashed_Maps in the Containers library) improved the speed by a factor
> of 5 (a result I didn't expect, because I had to use an expensive
> hash function -- all of the cheap ones I tried didn't work well on
> the actual data -- and log N wasn't that large -- between 12 and 19
> on the data I tested with). Moral: make sure you've exhausted
> algorithmic improvements before even thinking about squeezing a few
> extra percent out of the code. And when you think you've exhaused
> algorithmic improvements, try again, because sometimes non-obvious
> things work! (We hadn't originally used a hash because of the need to
> write sorted reports. But it turned out that using a hash and a
> quicksort on the report was faster than keeping the data sorted.)

I'd whole heartedly second this advice. It reminds me of a recent case
where a colleague had a program that seemed to be taking forever. I can't
recall what data structure he was using but he worked out that at it's
current speed it was going to need something fast approximating to the
entire life of the universe so far to complete! He switched to a 'quadtree'
and "bingo" - it only took a few (tens of) hours!

Cheers

-- Martin






  reply	other threads:[~2004-07-29  7:25 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-15 17:27 reading a text file into a string zork
2004-07-15 17:49 ` Marius Amado Alves
2004-07-15 19:57   ` Nick Roberts
2004-07-15 17:59 ` Marius Amado Alves
2004-07-15 19:18   ` Nick Roberts
2004-07-15 19:18 ` Nick Roberts
2004-07-15 20:02   ` Nick Roberts
2004-07-16  1:23 ` Jeffrey Carter
2004-07-16  2:20 ` Steve
2004-07-16  2:26 ` Steve
2004-07-16 16:16   ` Jeffrey Carter
2004-07-16 17:45     ` Nick Roberts
2004-07-16 21:19   ` Randy Brukardt
2004-07-17  2:27     ` Robert I. Eachus
2004-07-17 11:31       ` Mats Weber
2004-07-17 15:52         ` Robert I. Eachus
2004-07-17 22:38           ` Jeffrey Carter
2004-07-18 13:44             ` zork
2004-07-19  8:07       ` Dale Stanbrough
2004-07-19  8:58         ` Martin Dowie
2004-07-21  0:17           ` Robert I. Eachus
2004-07-21 21:39             ` Randy Brukardt
2004-07-22 22:34               ` Robert I. Eachus
2004-07-23  0:49                 ` Randy Brukardt
2004-07-23 21:56                   ` Nick Roberts
2004-07-24  0:34                     ` tmoran
2004-07-24  1:16                       ` Nick Roberts
2004-07-24  1:42                     ` Randy Brukardt
2004-07-24 15:14                       ` Nick Roberts
2004-07-26 23:48                         ` Randy Brukardt
2004-07-27 12:08                           ` Nick Roberts
2004-07-27 23:24                             ` Robert I. Eachus
2004-07-29  0:55                               ` Randy Brukardt
2004-07-29  0:53                             ` Randy Brukardt
2004-07-29  7:25                               ` Martin Dowie [this message]
2004-07-29 20:08                               ` Robert I. Eachus
2004-07-30  0:14                                 ` tmoran
2004-07-24  2:56                   ` Robert I. Eachus
2004-07-19 11:51       ` Ada2005 (was " Peter Hermann
2004-07-19 12:51         ` Dmitry A. Kazakov
2004-07-19 13:01         ` Nick Roberts
2004-07-19 13:35           ` Martin Dowie
2004-07-19 17:22             ` Nick Roberts
2004-07-19 23:50           ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox