From: Roy Turner <umcs.maine.edu at rmt>
o capturing *trace-output*, using the "time" macro to gather times, then
taking the returned string apart to get the time; the problem with this
is that you can't trace anything without modifying the code to not use
the time function, or to conditionally use the time function.
Why not this?
(defmacro my-time (form)
(let ((oto (gensym)))
`(let ((,oto *trace-output*))
(process-time-string ; However you parse the time output.
(with-output-to-string (*trace-output*)
(time (let ((*trace-output* ,oto)) ,form)))))))
This doesn't return the results of evaluating the timed form, but you
could easily fix that if you want transparency.
Since the
code is pretty stable, this isn't too bad, but they solution is hideously
inelegant -- there are obviously functions time is using to gather the
times, so using the intermediate string is dumb.
o using the undocumented function excl::get-internal-run-times in
conjunction with the standard get-internal-run-time to get the GC time:
The four returned values are in milliseconds:
user non-gc time
system non-gc time
user gc time
system gc time
If I were you I would carefully verify the reasonableness of the
returned values on whatever platform you are using, and don't depend
on this function working the same way in any future version or
different platform.