I'm definitely not the expert on this, but I just quickly subtracted the gc time from the cpu time and the times look pretty consistent:<div><br></div><div><div>> (- 7176 4537)</div><div>2639</div><div>> (- 5600 2949)</div>
<div>2651</div><div>> (- 4040 1388)</div><div>2652</div><div><br></div><div>Also, I would guess that cpu time adds the time of all cores or threads or whatever, so I assume there's some things happening in parallel? Just a guess.</div>
<br><div class="gmail_quote">On Wed, May 16, 2012 at 2:22 PM, Harry Spier <span dir="ltr"><<a href="mailto:vasishtha.spier@gmail.com" target="_blank">vasishtha.spier@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've just started using the "time" function to check the timings of<br>
some functions in my program. I'm testing the timings of two<br>
functions, each of these functions takes a list of lists and<br>
transforms it into another list of lists. The size of each list of<br>
lists is in the order of about 1000 x 1000.<br>
<br>
Each time I used it in DRacket I got very different results. So I did<br>
this test.<br>
I put three calls to the two functions right after each other in the<br>
program as follows.<br>
<br>
. . .<br>
(define page-as-binary-matrix (time (image-file->binary-matrix<br>
path-to-image-of-page)))<br>
(define black-pixel-matrix (time (create-matrix-of-black-pixel-ranges<br>
page-as-binary-matrix)))<br>
<br>
(define page-as-binary-matrix1 (time (image-file->binary-matrix<br>
path-to-image-of-page)))<br>
(define black-pixel-matrix1 (time (create-matrix-of-black-pixel-ranges<br>
page-as-binary-matrix)))<br>
<br>
(define page-as-binary-matrix2 (time (image-file->binary-matrix<br>
path-to-image-of-page)))<br>
(define black-pixel-matrix2 (time (create-matrix-of-black-pixel-ranges<br>
page-as-binary-matrix)))<br>
<br>
<br>
and got these results<br>
<br>
cpu time: 7176 real time: 6620 gc time: 4537<br>
cpu time: 2262 real time: 2289 gc time: 437<br>
<br>
cpu time: 5600 real time: 5257 gc time: 2949<br>
cpu time: 3728 real time: 3516 gc time: 1748<br>
<br>
cpu time: 4040 real time: 3673 gc time: 1388<br>
cpu time: 2418 real time: 2311 gc time: 422<br>
<br>
Its in DrRacket on a dual core pentium under windows.<br>
<br>
Why the widely divergent timings and why is CPU time in general more<br>
than real-time?<br>
<br>
Thanks,<br>
Harry<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br></div>