[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Measuring elapsed CPU time
- To: info-mcl
- Subject: Measuring elapsed CPU time
- From: email@example.com (John Kim)
- Date: 21 Jan 93 09:43:08 GMT
- Keywords: CPU time
- Newsgroups: comp.lang.lisp, comp.lang.lisp.mcl
- Organization: University of Southern California, Los Angeles, CA
- Summary: How do you measure elasped CPU time?
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)
(setq start-time (get-internal-run-time))
(setq end-time (get-internal-run-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