I want to capture the results of a call to the time
macro in order to gather multiple measurements and process them. I tried to locally setf
the standard output and redirect it to a string but it didn't work with the time
macro. Maybe it is wrong, but what I tried is:
(with-output-to-string (str)
(let ((*standard-output* str))
(time (test-with-size 40))))
The questions:
time
?slime-profile-report
command's output?What I want to accomplish is to measure the run-time of an algorithm as the size of the input increases so for each input size (ranging from 1 to 100) I will measure a lot of times and keep the average. Then I want to plot the results. Plotting is easy, and I have found many ways in Cliki, but how can I gather the results?
I am using CLISP and CCL.
EDIT: Paul Nathan pointed that the time
macro outputs to *trace-output*
which is a solution. I would like a nicer, simpler, solution though, because with this one, I have to parse an implementation specific trace.
If you want to capture the text, you need to use the right stream. The ANSI CL standard says that TIME prints to trace output.
So this would give you the text as a string.
(with-output-to-string (*trace-output*)
(time (sin 40.0)))
You could also write your own macro using the time primitives. See 25.1.4.3 Internal Time to get numeric data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With