Subject: Re: MzScheme & Mac timing problem
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 21 Sep 2001 02:22:41 GMT
Newsgroups: comp.lang.scheme
Message-ID: <9oe89h$knvof$1@fido.engr.sgi.com>
Stefan Schadwinkel <stefan.schadwinkel@s2000.tu-chemnitz.de> wrote:
+---------------
| running 6 times (current-milliseconds) gives something like this:
| 387650
| 387650
| 387650
| 387650
| 387666
| 387666
...
| does anyone know, why these silly values are generated...
+---------------

Probably because the hardware clock on that machine (or rather,
at least the clock presented to user programs) is a slow clock?

Try running the following and see what you get. On my Unix box,
I get clean millisecond ticks:

> (define x
    (let loop ((i 0) 
	       (loops-per-tick 0)
	       (accum '())
	       (last 0)) 
      (let ((this (current-milliseconds)))
	(cond
	  ((>= i 10)
	   (reverse accum))
	  ((eqv? this last)
	   (loop i (+ loops-per-tick 1) accum this))
	  (else
	   (let ((item (cons (- this last) loops-per-tick)))
	     (loop (+ i 1) 0 (cons item accum) this)))))))
> (cddr x) ; ignore first two
((1 . 39) (1 . 41) (1 . 40) (1 . 39) (1 . 27) (1 . 38) (1 . 39) (1 . 39))
> 

+---------------
| when computing differences or using time-apply,mot values are divisible
| by 100, meaning one tenth of second accurancy which is not good enough..
| ...and much important, how can I work around this problem.
+---------------

Do more work between calls to (current-milliseconds), perhaps?

Or change a system configuration to use higher-resolution clocks?
[That works on some Unix systems...]


-Rob

-----
Rob Warnock, 30-3-510		<rpw3@sgi.com>
SGI Network Engineering		<http://reality.sgi.com/rpw3/>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA