[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: emcoop@bnr.ca (hume smith)
- Date: 21 Jan 93 14:18:40 GMT
- In-reply-to: joungwoo@mensa.usc.edu's message of 21 Jan 1993 01:43:08 -0800
- Newsgroups: comp.lang.lisp, comp.lang.lisp.mcl
- Organization: Bell-Northern Research, Ottawa, Canada
- References: <1jlr7cINNep1@mensa.usc.edu>
- Sender: news@bnr.ca (usenet)
In article <1jlr7cINNep1@mensa.usc.edu> joungwoo@mensa.usc.edu (John Kim) writes:
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
in msecs.
"
(let ((start-time nil)
(end-time nil)
)
(setq start-time (get-internal-run-time))
form
(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?
this sort of thing needs a macro. in your construct, the form has been evaled by the time
the function starts, and all your timer ends up timing is how long it takes the
evaluator to find the value of the symbol "form". try this:
(defmacro CPU-time (form)
`(let (start-time end-time)
(setq start-time (get-internal-run-time))
,form
(setq end-time (get-internal-run-time))
(print start-time)
(print end-time)
(- end-time start-time)))
--
Hume Smith Honour sick and davey cris-cross
hume.smith@acadiau.ca McTruloff sentimie
emcoop@bnr.ca A parsnip inner pair threes.