[racket] help me speed up string split?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Jun 18 02:26:37 EDT 2014

Could it be the float parser? Do you actually get the same floats in
both versions?

Robby


On Wed, Jun 18, 2014 at 1:03 AM, Ryan Davis <zenspider at gmail.com> wrote:
>
> On Jun 17, 2014, at 22:24, Neil Van Dyke <neil at neilvandyke.org> wrote:
>
>> Well, you could read only 10 times, rather than 4000000. :)
>>
>> Another option is to do repeated regexp matching on the front of the file input port, but I'd think "read" would be faster.  (Be sure to anchor the regexp with "^" to the start of input, and experiment with limiting the lookahead.)
>
> Given that the file is fixed width, I came up with the following speed up:
>
>         (time                                   ; 9464 ms
>          (take
>           (with-input-from-file path
>             (lambda ()
>               (for/list ([s (in-port (curry read-string 16))])
>                 (string->number (string-trim s)))))
>           10))
>
> tho, come to think of it, I'm not dealing with newlines properly...
>
> Still, 3x slower than my doofy ruby version.
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.