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:
> (- 7176 4537) 2639 > (- 5600 2949) 2651 > (- 4040 1388) 2652 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. On Wed, May 16, 2012 at 2:22 PM, Harry Spier <vasishtha.sp...@gmail.com>wrote: > I've just started using the "time" function to check the timings of > some functions in my program. I'm testing the timings of two > functions, each of these functions takes a list of lists and > transforms it into another list of lists. The size of each list of > lists is in the order of about 1000 x 1000. > > Each time I used it in DRacket I got very different results. So I did > this test. > I put three calls to the two functions right after each other in the > program as follows. > > . . . > (define page-as-binary-matrix (time (image-file->binary-matrix > path-to-image-of-page))) > (define black-pixel-matrix (time (create-matrix-of-black-pixel-ranges > page-as-binary-matrix))) > > (define page-as-binary-matrix1 (time (image-file->binary-matrix > path-to-image-of-page))) > (define black-pixel-matrix1 (time (create-matrix-of-black-pixel-ranges > page-as-binary-matrix))) > > (define page-as-binary-matrix2 (time (image-file->binary-matrix > path-to-image-of-page))) > (define black-pixel-matrix2 (time (create-matrix-of-black-pixel-ranges > page-as-binary-matrix))) > > > and got these results > > cpu time: 7176 real time: 6620 gc time: 4537 > cpu time: 2262 real time: 2289 gc time: 437 > > cpu time: 5600 real time: 5257 gc time: 2949 > cpu time: 3728 real time: 3516 gc time: 1748 > > cpu time: 4040 real time: 3673 gc time: 1388 > cpu time: 2418 real time: 2311 gc time: 422 > > Its in DrRacket on a dual core pentium under windows. > > Why the widely divergent timings and why is CPU time in general more > than real-time? > > Thanks, > Harry > ____________________ > Racket Users list: > http://lists.racket-lang.org/users >
____________________ Racket Users list: http://lists.racket-lang.org/users