[racket] Reversing strings (Jay's article)

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Oct 2 19:37:26 EDT 2013

I'm not sure what is happening in Geiser, but DrRacket should definitely
not be trusted. Here's the relevant section of the docs (feel free to ask
more questions if that's not helping):

  http://docs.racket-lang.org/guide/performance.html

Robby


On Wed, Oct 2, 2013 at 6:29 PM, Vlad Kozin <vladilen.kozin at gmail.com> wrote:

> Oh, wow. So I was testing this in Geiser repl in emacs:
> (2467 4631 4088 3934) Where apparently "slower" one wins
>
> But in DrRacket the result looks plausible:
> (8994 1859 1094 865)
>
> Does that mean Geiser shouldn't be trusted?
>
> ---
> Vlad Kozin <vladilen.kozin at gmail.com>
>
>
>
> On Oct 2, 2013, at 1:57 PM, Laurent wrote:
>
> What values do you get?
> For 4'000 strings (old slow computer), I get:
> (236 148 84 84)
> for slow, medium, fast, really fast, which is consistent with Jay's post.
>
> Laurent
>
>
> On Wed, Oct 2, 2013 at 7:28 PM, Vlad Kozin <vladilen.kozin at gmail.com>wrote:
>
>> Mostly a question to Jay McCarthy but I suppose could be interesting to
>> others. Was going over his Reversing strings<http://jeapostrophe.github.io/2013-08-19-reverse-post.html> article.
>> Somehow I get weird performance. Slowest solution turns out fastest,
>> medium, fast and really fast are only marginally different.
>>
>> Could anyone have a look https://github.com/vkz/warm-up
>> reverse-string.rkt has the solutions
>> test-reverse-string.rkt does the performance check
>> Testing it on 40'000 randomly generated strings 1000 chars each.
>>
>> While we're at it, why do we garbage-collect thrice here?
>> let-values<http://docs.racket-lang.org/reference/let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29>
>>  ([(as cpu real gc) (time-apply<http://docs.racket-lang.org/reference/time.html#%28def._%28%28quote._~23~25kernel%29._time-apply%29%29>
>>  (λ<http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29>
>>  () exp<http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._exp%29%29>
>> ) empty<http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._empty%29%29>
>> )])     (collect-garbage<http://docs.racket-lang.org/reference/garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29>
>> ) (collect-garbage<http://docs.racket-lang.org/reference/garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29>
>> ) (collect-garbage<http://docs.racket-lang.org/reference/garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29>
>> )
>>
>> Thanks!
>> ---
>> Vlad Kozin <vladilen.kozin at gmail.com>
>>
>>
>>
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131002/aefa3672/attachment.html>

Posted on the users mailing list.