[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cambridge archive contribution: High resolution timer



Having written too many (TIME (DOTIMES ... ) forms in my sad Lisp
programmer's live on many different HW/SW platforms to determine the
time it takes to run certain parts of my code I finally decided to
write a simple timer package to deal with all the time consuming
tweaking (adjusting the number of loops, writing an empty compensation
loop, compiling the thing - on some machines -, computing the real
time, tacking noise into consideration, blah bla.. ).

Anyway, so I contribute "hires-timer.lisp" to the cambridge archive
"/pub/mcl2/contrib"


  May it help you to write fewer dotimes forms in the future,


  Alex Repenning
  University of Colorado


------------ 8X ---- some more info -------- X8 -------------

Author:     Alex Repenning, ralex@cs.colorado.edu              
            Copyright (c) 1992 Alex Repenning                  
Address:    Computer Science Department                        
            University of Colorado at Boulder                  
            Boulder, CO 80309-0430                             
                                                               
Filename:   hires-timer.lisp                                   
Update:     3/14/92                                            
Version:                                                       
  1.0  10/18/91 Alex Repenning                                 
  1.1   1/ 8/92 Alex: CLtL2                                    
  1.2   2/22/92 Alex & Brent Reeves: Symbolics                 
System:     Macintosh II, MCL 2.0                              
Abstract:   Not your father's TIME macro anymore.              
  Have you ever written code like:                             
    (time (dotimes (i 10000..) <some-form-to-be-timed>))       
  .. then this is for you! No more playing with the number of  
  times to call your code, measure time of an empty dotimes,   
  compilation, etc.                                            
  The whole thing started really small and got out of hand     
  big time.                                                    
Features:                                                      
  - High Resolution: gives you the time it takes to eval forms 
      with a resolution much better than that of the built-in  
      TIME macro.                                              
  - Portable: Only relies on Common Lisp functionality.        
  - (Mac only) FRED Timer command: c-x c-t TIME-OF-SEXP        
Status: interesting hack                                       
How: compile the form to be tested, call it as many times as   
  required to determine the time it takes. Compare the time    
  with the time of an empty loop.                              
Bugs, Problems: It may take a while to determine the time if   
  the form to be timed is very fast (e.g., (SVREF ..)).