home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.lisp:3352 comp.lang.lisp.mcl:2086
- Path: sparky!uunet!usc!usc!not-for-mail
- From: joungwoo@mensa.usc.edu (John Kim)
- Newsgroups: comp.lang.lisp,comp.lang.lisp.mcl
- Subject: Re: Measuring elapsed CPU time
- Date: 24 Jan 1993 18:47:34 -0800
- Organization: University of Southern California, Los Angeles, CA
- Lines: 65
- Message-ID: <1jvkc6INN10n@mensa.usc.edu>
- References: <1jlr7cINNep1@mensa.usc.edu>
- NNTP-Posting-Host: mensa.usc.edu
- Keywords: CPU time
-
- 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.
-
- John
-
-
-
- joungwoo@mensa.usc.edu (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
- >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
-
- --
- Joung-woo John Kim joungwoo@mensa.usc.edu
- Computer Science Dept.
- University of Southern California, Los Angeles, CA 90089-0781
-
-