I would like to time knitr chunks and record how long it took to render them using comments in LaTeX output.
I\'ve tried the following hook:
now = S
Try this:
local({
now = Sys.time()
knit_hooks$set(timeit = function(before) {
if (before) {
now <<- Sys.time()
} else {
x = round(Sys.time() - now, digits = 3)
x = sprintf("%% Chunk rendering time: %s seconds.", x)
paste('\\end{kframe}\n', x, '\n\\begin{kframe}')
}
})
})
It is a hack, though. Basically you escape the LaTeX comment from the kframe
environment.