views:

115

answers:

2

I'm trying to time an order statistic function implemented in SBCL. Googling around I found this timing function: (time form). However I'm not sure what it returns. It seems to be a large number but I can't find documentation specifying if the return value is milliseconds, nanoseconds, system time, etc.

Does anyone know?

+7  A: 

The TIME macro is specified to “pass trough” the value of whatever it runs. In this way, it is like PRINT (i.e. you can wrap TIME or PRINT around anything without changing the internal dataflow—they do add stuff to the output though). (time (foo)) returns whatever (foo) would return.

The specification provides no hard requirements as to what information is printed, that part is implementation specific.

Depending on your requirements, you might be better off looking for a profiling package (SBCL has a couple, I believe). Otherwise, you might like to look at GET-INTERNAL-RUN-TIME, GET-INTERNAL-REAL-TIME, and INTERNAL-TIME-UNITS-PER-SECOND.

Chris Johnsen
+1  A: 

Use GET-INTERNAL-REAL-TIME and INTERNAL-TIME-UNITS-PER-SECOND to find out programmatically how long your code takes to execute.

skypher