home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / lisp / 3306 < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.0 KB  |  58 lines

  1. Xref: sparky comp.lang.lisp:3306 comp.lang.lisp.mcl:2063
  2. Path: sparky!uunet!usc!usc!not-for-mail
  3. From: joungwoo@mensa.usc.edu (John Kim)
  4. Newsgroups: comp.lang.lisp,comp.lang.lisp.mcl
  5. Subject: Measuring elapsed CPU time
  6. Date: 21 Jan 1993 01:43:08 -0800
  7. Organization: University of Southern California, Los Angeles, CA
  8. Lines: 44
  9. Message-ID: <1jlr7cINNep1@mensa.usc.edu>
  10. NNTP-Posting-Host: mensa.usc.edu
  11. Summary: How do you measure elasped CPU time?
  12. Keywords: CPU time
  13.  
  14.  
  15. I'm trying to measure teh elasped CPU time during a lisp form has been run.
  16. The problem with the Common Lisp's builtin function TIME is that it does not
  17. return the various elapsed times but returns the return value of the form
  18. (ie, TIME's arg) plus I don't know if I am getting accurate elapsed CPU time
  19. either. 
  20.     So I tried using builtin function GET-INTERNAL-RUN-TIME as follows,
  21. but the following function defined by me usually it gives me either 0 or 1 no
  22. matter how time-consuming task I give it. 
  23.  
  24. (defun CPU-time (form)
  25.   "returns the actual elapsed CPU(?) time not including I/O processing 
  26. in msecs.
  27. "
  28.   (let ((start-time nil)
  29.         (end-time nil)
  30.         )
  31.     (setq start-time (get-internal-run-time))
  32.     form
  33.     (setq end-time (get-internal-run-time))
  34.     (print start-time)
  35.     (print end-time)
  36.     (- end-time start-time)
  37.     ))
  38.  
  39. Am I doing something wrong in the above function definition or is there a
  40. better way to do this? Or are most tasks heavily I/O bound but so lightly
  41. CPU-bound that the internal clock for GET-INTERNAL-RUN-TIME hardly ticks?
  42.  
  43. Thank you in advance. (Please email me.)
  44.  
  45. John
  46.  
  47. P.S. I tried both Lucid Common Lisp/Sparc on Sun and Macintosh Common Lisp
  48. (MCL 2.0) and the result is the same.
  49.  
  50. P.P.S. In the worst case, is there a way to print the msg (not the return
  51. value) of TIME which goes to *TRACE-OUTPUT* to a string (so I can parse teh
  52. string later)?
  53. -- 
  54. Joung-woo John Kim                joungwoo@mensa.usc.edu
  55. Computer Science Dept.
  56. University of Southern California, Los Angeles, CA 90089-0781
  57.  
  58.