[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Measuring elapsed CPU time
- To: info-mcl
- Subject: Re: Measuring elapsed CPU time
- From: firstname.lastname@example.org (John Kim)
- Date: 25 Jan 93 02:47:34 GMT
- Keywords: CPU time
- Newsgroups: comp.lang.lisp, comp.lang.lisp.mcl
- Organization: University of Southern California, Los Angeles, CA
- References: <1jlr7cINNep1@mensa.usc.edu>
I would like to thank everyone who emailed me or posted an answer on this BB
for an elementary question. (I knew lisp function's args are evaled first,
but the fact just slipped out when I was doing my coding.:-]) I could have
guessed using defmacro. But many of your alternative answers were extensive
and beyond just using macros.
Frankly I have received ENOUGH answers by now. I'll post a summary soon.
Thank you all again. Netters are wonderful.
email@example.com (John Kim) writes:
>I'm trying to measure teh elasped CPU time during a lisp form has been run.
>The problem with the Common Lisp's builtin function TIME is that it does not
>return the various elapsed times but returns the return value of the form
>(ie, TIME's arg) plus I don't know if I am getting accurate elapsed CPU time
> So I tried using builtin function GET-INTERNAL-RUN-TIME as follows,
>but the following function defined by me usually it gives me either 0 or 1 no
>matter how time-consuming task I give it.
>(defun CPU-time (form)
> "returns the actual elapsed CPU(?) time not including I/O processing
> (let ((start-time nil)
> (end-time nil)
> (setq start-time (get-internal-run-time))
> (setq end-time (get-internal-run-time))
> (print start-time)
> (print end-time)
> (- end-time start-time)
>Am I doing something wrong in the above function definition or is there a
>better way to do this? Or are most tasks heavily I/O bound but so lightly
>CPU-bound that the internal clock for GET-INTERNAL-RUN-TIME hardly ticks?
>Thank you in advance. (Please email me.)
>P.S. I tried both Lucid Common Lisp/Sparc on Sun and Macintosh Common Lisp
>(MCL 2.0) and the result is the same.
>P.P.S. In the worst case, is there a way to print the msg (not the return
>value) of TIME which goes to *TRACE-OUTPUT* to a string (so I can parse teh
>Joung-woo John Kim firstname.lastname@example.org
>Computer Science Dept.
>University of Southern California, Los Angeles, CA 90089-0781
Joung-woo John Kim email@example.com
Computer Science Dept.
University of Southern California, Los Angeles, CA 90089-0781