Using time--Please Help 
Author Message
 Using time--Please Help

Hi,
Please can someone tell me where is the problem?
I used a "clock-1" procedure to convert a time given in milliseconds into the format " h:m:s:ms " where h represents the number of hours, m the number of minutes, s for seconds and ms for milliseconds.
here is the procedure

(define (clock-1 x)
  (define (find-hours)
    (quotient x 3600000))
  (define (rest-from-hours)
    (remainder x 3600000))
  (define (find-minutes)
    (quotient (rest-from-hours) 60000))
  (define (rest-from-minutes)
    (remainder x 60000))
  (define (find-seconds)
    (quotient (rest-from-minutes) 1000))
  (define (rest-from-seconds)
    (remainder (rest-from-minutes) 1000))
  (define (find-ms)
    (rest-from-seconds) )

  (display (find-hours))
  (display ":")
  (display (find-minutes))
  (display ":")
  (display (find-seconds))
  (display ":")
  (display (find-ms))
  (newline))

Now I want to use "clock-1" to compute the time taken by the execution of  "(rec-expt 1 3000)" where

(define (rec-expt x y)
  (define (expt y)
    (if (= y 0)
        1
        (* x (expt (- y 1)))))
  (if (>= y 0)
      (expt y)
      (/ 1 (expt (abs y)))))

So I put the following

(clock-1 (time (rec-expt 1 3000)))
(time (rec-expt 1 3000))

It should return the same results, at least "0:0:1:563 "here the problem, the results are

Quote:
>(clock-1 (time (rec-expt 1 3000)))

(time (rec-expt 1 3000))
    5 collections
    1563 ms elapsed cpu time (user+system time), including 1533 ms collecting
0:0:0:1        ???
Quote:
>(time (rec-expt 1 3000))

(time (rec-expt 1 3000))
    5 collections
    1552 ms elapsed cpu time (user+system time), including 1502 ms collecting
1

The two returned times are different and(time (rec-expt 1 3000)) should return  "0:0:1:563 "  where is the problem?



Sun, 05 May 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. please, please, please, please, help

2. will someone please, please, please, please HELP me?!!

3. Quick Time help, PLEASE...

4. Please Help - Retreiving File Acces and Modify Times

5. ! (A.S.A.P) Help Please Creating Menu Choices At Run-Time

6. Run Time Error - Please Help

7. Compile time Error Please Help ASAP

8. Time Travelers PLEASE HELP! 1796

9. HArd time writing a test bench, please help (0/1)

10. please help stuck with report date and time

11. run time error 198 PLEASE HELP ME

12. System call, TIME, in FORTRAN on HP-UX 8.0: PLEASE HELP

 

 
Powered by phpBB® Forum Software