[racket] Performance help

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Jan 2 21:18:56 EST 2015

On Jan 2, 2015, at 11:38 AM, Jens Axel Søgaard wrote:

> 2015-01-02 17:10 GMT+01:00 Matthias Felleisen <matthias at ccs.neu.edu>:
>> 
>> Jens -- thanks for re-directing us to your article. This saved me quite
>> some time. I noticed the lacking abstractions (slicing, comprehension)
>> and considered sketching a prototype to use with this program. I decided
>> to wait till today because it didn't address what bothered me most:
>> 
>> speed.
> 
> One trick: change the regular expression in  words  in order to
> get rid of the call to string-downcase:
> 
>   (regexp-split #rx"[^a-zA-Z]" buf)
> 
> Another trick: the regular expression matchers in Racket works both
> on strings and ports, so  train  can be written
> 
>    (define (train fname)
>       (freqs (words (open-input-file fname))))
> 
> I am not sure whether it will give a speedup though.


Both of these caused a serious slowdown. -- Matthias



Posted on the users mailing list.