timing_data: Get the timing data of code chunks and text blocks in a...

View source: R/fuse.R

timing_dataR Documentation

Get the timing data of code chunks and text blocks in a document

Description

Timing can be enabled via the chunk option time = TRUE (e.g., set reactor(time = TRUE) in the first code chunk). After it is enabled, the execution time for code chunks and text blocks will be recorded. This function can be called to retrieve the timing data later in the document (e.g., in the last code chunk).

Usage

timing_data(threshold = 0, sort = TRUE, total = TRUE)

Arguments

threshold

A number (time in seconds) to subset data with. Only rows with time above this threshold are returned.

sort

Whether to sort the data by time in the decreasing order.

total

Whether to append the total time to the data.

Value

A data frame containing input file paths, line numbers, chunk labels, and time. If no timing data is available, NULL is returned.

Note

By default, the data will be cleared after each call of fuse() and will not be available outside fuse(). To store the data persistently, you can set the time option to a file path. This is necessary if you want to get the timing data for multiple input documents (such as all chapters of a book). Each document needs to point the time option to the same path. When you do not need timing any more, you will need to delete this file by yourself.


litedown documentation built on Oct. 17, 2024, 1:06 a.m.