<HTML><BODY>Yet more strange<br><br>(define (run3 data)<br> (map (test2 #t) data))<br><br>runs twice faster. (time ...) gives only 100.<br><br>I thought, that (lambda (x) (k x)) and k -- are synonims and optimizer elide extra lambda.<br><br><br><br>Mon, 16 Jun 2014 11:16:25 +0400 от Roman Klochkov <kalimehtar@mail.ru>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
<div id="">
<div class="js-helper js-readmsg-msg">
<style type="text/css"></style>
<div>
<base target="_self" href="https://e.mail.ru/">
<div id="style_14029029850000000029_BODY">
Strange.<br><br><p>#lang racket<br>(define (test1 x y)<br> (if x<br> (+ y 1)<br> (- y 1)))</p><p>(define (test2 x)<br> (if x<br> (λ (y) (+ y 1))<br> (λ (y) (- y 1))))</p><p>(define (run1 data)<br> (map (λ (x) (test1 #t x)) data))</p><p>(define (run2 data)<br> (map (λ (x) ((test2 #t) x)) data))</p>I expect, that run2 should be faster, because (test2 #t) returns const (lambda (y) (+ y 1)) and shouldn't be checked on every iteration.<br><br>But in reality (time ...) gives 219 for run1 and 212 for run2. run2 is 1.5 times slower!<br><br>Why so?<br><br><br>-- <br>Roman Klochkov
</div>
<base target="_self" href="https://e.mail.ru/">
</div>
</div>
</div>
</blockquote>
<br>
<br>-- <br>Roman Klochkov<br></BODY></HTML>