home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.lisp:3308 comp.lang.lisp.mcl:2065
- Newsgroups: comp.lang.lisp,comp.lang.lisp.mcl
- Path: sparky!uunet!cs.utexas.edu!torn!nott!bnrgate!bcars267!bcars267!emcoop
- From: emcoop@bnr.ca (hume smith)
- Subject: Re: Measuring elapsed CPU time
- In-Reply-To: joungwoo@mensa.usc.edu's message of 21 Jan 1993 01:43:08 -0800
- Message-ID: <EMCOOP.93Jan21091840@bcars148.bnr.ca>
- Sender: news@bnr.ca (usenet)
- Nntp-Posting-Host: bcars148
- Organization: Bell-Northern Research, Ottawa, Canada
- References: <1jlr7cINNep1@mensa.usc.edu>
- Date: Thu, 21 Jan 1993 14:18:40 GMT
- Lines: 40
-
- 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.
-