<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Mostly a question to Jay McCarthy but I suppose could be interesting to others. Was going over his <a href="http://jeapostrophe.github.io/2013-08-19-reverse-post.html">Reversing strings</a> article. Somehow I get weird performance. Slowest solution turns out fastest, medium, fast and really fast are only marginally different.<div><br></div><div>Could anyone have a look <a href="https://github.com/vkz/warm-up">https://github.com/vkz/warm-up</a></div><div>reverse-string.rkt has the solutions</div><div>test-reverse-string.rkt does the performance check</div><div>Testing it on 40'000 randomly generated strings 1000 chars each.</div><div><br></div><div>While we're at it, why do we garbage-collect thrice here?</div><div><table cellspacing="0" class="RktBlk" style="font-family: monospace; white-space: nowrap; text-align: left; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><tbody><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29" class="RktStxLink" data-pltdoc="x" style="text-decoration: none; color: black;">let-values</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">[</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">as</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">cpu</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">real</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);">gc</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/time.html#%28def._%28%28quote._~23~25kernel%29._time-apply%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">time-apply</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x" style="text-decoration: none; color: black;">λ</a></span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._exp%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">exp</a></span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._empty%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">empty</a></span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">]</span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span></td></tr><tr style="white-space: inherit;"><td style="padding-left: 0px; padding-right: 0px; vertical-align: baseline; white-space: inherit;"><span class="hspace" style="font-family: monospace;">    </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">collect-garbage</a></span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">collect-garbage</a></span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span><span class="hspace" style="font-family: monospace;"> </span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">(</span><span class="RktSym" style="font-family: monospace; white-space: inherit; color: rgb(38, 38, 128);"><a href="http://docs.racket-lang.org/reference/garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="RktValLink" data-pltdoc="x" style="text-decoration: none; color: blue;">collect-garbage</a></span><span class="RktPn" style="font-family: monospace; white-space: inherit; color: rgb(132, 60, 36);">)</span></td></tr></tbody></table><div><br></div><div>Thanks!</div></div><div>---</div><div><div apple-content-edited="true"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Vlad Kozin <<a href="mailto:vladilen.kozin@gmail.com">vladilen.kozin@gmail.com</a>><br><br><br></div></div>
</div>
<br></div></body></html>