home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.lisp:3306 comp.lang.lisp.mcl:2063
- Path: sparky!uunet!usc!usc!not-for-mail
- From: joungwoo@mensa.usc.edu (John Kim)
- Newsgroups: comp.lang.lisp,comp.lang.lisp.mcl
- Subject: Measuring elapsed CPU time
- Date: 21 Jan 1993 01:43:08 -0800
- Organization: University of Southern California, Los Angeles, CA
- Lines: 44
- Message-ID: <1jlr7cINNep1@mensa.usc.edu>
- NNTP-Posting-Host: mensa.usc.edu
- Summary: How do you measure elasped CPU time?
- Keywords: 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
- either.
- 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? 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.)
-
- John
-
- 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
- string later)?
- --
- Joung-woo John Kim joungwoo@mensa.usc.edu
- Computer Science Dept.
- University of Southern California, Los Angeles, CA 90089-0781
-
-