<HTML><BODY>I have "debugging & profiling" on.<br><br>Disable debugging. Now have all zeroes :-)<br> cpu time: 0 real time: 0 gc time: 0<br><br>I will check with optimization. If find something strange, I'll write.<br><br><br>Mon, 16 Jun 2014 08:58:16 +0100 от Matthew Flatt <mflatt@cs.utah.edu>:<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_14029055100000000222_BODY">Hm... I'm not able to get anything like the results you're reporting.<br>
When I run the enclosed program via `racket` on the command line, I get<br>
<br>
 cpu time: 3 real time: 3 gc time: 0<br>
 cpu time: 3 real time: 3 gc time: 0<br>
 cpu time: 2 real time: 2 gc time: 0<br>
 cpu time: 3 real time: 3 gc time: 0<br>
 cpu time: 5 real time: 5 gc time: 3<br>
 cpu time: 2 real time: 2 gc time: 0<br>
 cpu time: 2 real time: 2 gc time: 0<br>
 cpu time: 2 real time: 2 gc time: 0<br>
 cpu time: 4 real time: 4 gc time: 1<br>
<br>
Running in DrRacket gives messier results, such as<br>
<br>
 cpu time: 17 real time: 10 gc time: 0<br>
 cpu time: 19 real time: 22 gc time: 0<br>
 cpu time: 7 real time: 7 gc time: 0<br>
 cpu time: 15 real time: 8 gc time: 0<br>
 cpu time: 14 real time: 10 gc time: 0<br>
 cpu time: 10 real time: 10 gc time: 0<br>
 cpu time: 7 real time: 6 gc time: 0<br>
 cpu time: 7 real time: 7 gc time: 0<br>
 cpu time: 23 real time: 29 gc time: 15<br>
<br>
or<br>
<br>
 cpu time: 6 real time: 6 gc time: 0<br>
 cpu time: 5 real time: 4 gc time: 0<br>
 cpu time: 58 real time: 57 gc time: 49<br>
 cpu time: 6 real time: 5 gc time: 0<br>
 cpu time: 5 real time: 4 gc time: 0<br>
 cpu time: 6 real time: 6 gc time: 0<br>
 cpu time: 5 real time: 5 gc time: 0<br>
 cpu time: 5 real time: 4 gc time: 0<br>
 cpu time: 15 real time: 16 gc time: 9<br>
<br>
I'm using v6.0.1.12 on Mac OS X 64-bit on a MacBook Pro. Version 6.0.1<br>
on the same machine seems to produce the same sorts of results.<br>
<br>
Any idea what might be different?<br>
<br>
At Mon, 16 Jun 2014 11:44:41 +0400, Roman Klochkov wrote:<br>
>  (define data (for/list ([x 100000]) x))<br>
> <br>
> (time (begin0 (void) (run2 data)))<br>
> (time (begin0 (void) (run1 data)))<br>
> <br>
> 3 times run1, then 3 times run2, then again 3 times run1.<br>
> <br>
> Results are stable.<br>
> <br>
> Mon, 16 Jun 2014 08:28:10 +0100 от Matthew Flatt <<a href="/compose?To=mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>>:<br>
> >I'd expect them to run nearly the same due to inlining and constant<br>
> >propagation. If I save your program to "ex.rkt" and use<br>
> ><br>
> > raco make ex.rkt<br>
> > raco decompile ex.rkt<br>
> ><br>
> >the the output looks almost the same for both functions.<br>
> ><br>
> >There's a lot of allocation in these programs, of course, and that's<br>
> >going to make benchmarking relatively tricky. How are you timing the<br>
> >functions, and does it matter whether you `run1` or `run2` first?<br>
> ><br>
> >At Mon, 16 Jun 2014 11:16:25 +0400, Roman Klochkov wrote:<br>
> >>  Strange.<br>
> >> <br>
> >> #lang racket<br>
> >> (define (test1 x y)<br>
> >>   (if x<br>
> >>     (+ y 1)<br>
> >>     (- y 1)))<br>
> >> (define (test2 x)<br>
> >>   (if x<br>
> >>     (λ (y) (+ y 1))<br>
> >>     (λ (y) (- y 1))))<br>
> >> (define (run1 data)<br>
> >>   (map (λ (x) (test1 #t x)) data))<br>
> >> (define (run2 data)<br>
> >>   (map (λ (x) ((test2 #t) x)) data)) I expect, that run2 should be faster, <br>
> >> because (test2 #t) returns const (lambda (y) (+ y 1)) and shouldn't be <br>
> checked <br>
> >> on every iteration.<br>
> >> <br>
> >> But in reality (time ...) gives 219 for run1 and 212 for run2. run2 is 1.5 <br>
> >> times slower!<br>
> >> <br>
> >> Why so?<br>
> >> <br>
> >> <br>
> >> -- <br>
> >> Roman Klochkov____________________<br>
> >>   Racket Users list:<br>
> >>  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
> <br>
> <br>
> -- <br>
> Roman Klochkov<br>
> ____________________<br>
>   Racket Users list:<br>
>   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div>
                        
                
                <base target="_self" href="https://e.mail.ru/">
        </div>

        
</div>


</div>
</blockquote>
<br>
<br>-- <br>Roman Klochkov<br></BODY></HTML>