Friday, February 20, 2009

lisp time function

I am noticing that the results of the time function when I run it on my system are in seconds. Thus most of the results are rounded to 0.0 secs for runtime, etc. As far as I can tell, the time function has no other parameters than the form being timed. I am wondering if anyone has figured out how to force the time function to output in any smaller unit of time.

3 comments:

  1. Run your code a thousand times in a loop inside the time function to find the time in milliseconds :D

    ReplyDelete
  2. If you're using a *ix box, you can use the time command if you can figure out how to invoke the interpreter in a non-interactive mode.

    ReplyDelete
  3. I think he's more interested in a lisp function that generates the same output as in the sample:

    USER(110): (time (loop for x from 1 to 1000 do ( + x x)))
    ; cpu time (non-gc) 130 msec user, 10 msec system
    ; cpu time (gc) 140 msec user, 0 msec system
    ; cpu time (total) 270 msec user, 10 msec system
    ; real time 390 msec
    ; space allocation:
    ; 24,125 cons cells, 0 symbols, 88,120 other bytes
    NIL


    As opposed to this, which I'm getting and he is too, apparently:

    Real time: 0.0 sec.
    Run time: 0.0 sec.
    Space: 45764 Bytes

    ReplyDelete

Note: Only a member of this blog may post a comment.