Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the SBCL time function return?

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?

like image 723
Frank Avatar asked Jan 23 '23 00:01

Frank


2 Answers

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.

like image 174
Chris Johnsen Avatar answered Jan 29 '23 08:01

Chris Johnsen


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

like image 44
Leslie P. Polzer Avatar answered Jan 29 '23 09:01

Leslie P. Polzer