[Haskell-cafe] Optimizing a title matcher

Lyle Kopnicky lists at qseep.net
Wed Sep 27 00:25:45 EDT 2006

Bertram Felgenhauer wrote:
> Lyle Kopnicky wrote:
> [snip]
>> listRecords :: AbsString s => TextTable s -> IO [TextRecord s]
>> listRecords (TextTable fields _ records) = do
>>   keyRecs <- HT.toList records
>>   return $ map (fromList . zip fields . elems . snd) keyRecs
> Doing fromList again and again can't be good. Why don't you make
> tableFields a map that maps names to array indices? Then you can just
> pass the bare arrays along, and the later lookups will be cheaper, too.
That might make a difference. It does spoil the interface a bit, since 
now the caller has to look up a field name to get an index, then use 
that to look up a value, instead of just using the field name to get the 
> Now due to lazyness this will probably be evaluated in matchscore,
> because before that the resulting Map isn't used. Which is exactly where
> you said a lot (most?) of the time is spent.
Yes, likely. I had to run on a small pair of files in order to get the 
profiling to work. So, probably more time was spent in matchScore than 
it admitted. (The overhead of the initial read would decrease as the 
table size increases.)
> Another thing is that you should compile your code with -O, but I guess
> you are already doing that.
Yep. Thanks.

- Lyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20060926/f216af34/attachment.htm

More information about the Haskell-Cafe mailing list