references_best | R Documentation |
Compute best asymptotic references.
references_best(L, unit.col.vec=NULL, more.units=NULL, fun.list=NULL)
L |
List output from atime. |
unit.col.vec |
Named character vector of units, default NULL means standard units (kilobytes and seconds). |
more.units |
Named character vector of units to add to
|
fun.list |
List of asymptotic complexity reference functions, default NULL means to use package default. |
list of class "references_best"
with elements
references
(data table of references),
measurements
(data table of measurements).
Toby Dylan Hocking
## Example 1: polynomial and exponential time string functions.
string.result <- atime::atime(
N=unique(as.integer(10^seq(0,3.5,l=100))),
setup={
subject <- paste(rep("a", N), collapse="")
pattern <- paste(rep(c("a?", "a"), each=N), collapse="")
},
seconds.limit=0.001,
PCRE.match=regexpr(pattern, subject, perl=TRUE),
TRE.match=regexpr(pattern, subject, perl=FALSE),
constant.replacement=gsub("a","constant size replacement",subject),
linear.replacement=gsub("a",subject,subject))
(string.best <- atime::references_best(string.result))
## plot method shows each expr in a separate panel.
plot(string.best)
## Example 2: split data table vs frame, constant factor difference.
library(data.table)
split.result <- atime::atime(
N=as.integer(10^seq(1, 7)),
setup={
set.seed(1)
DT <- data.table(
x1 = rep(c("c","d"), l=N),
x2 = rep(c("x","y"), l=N),
x3 = rep(c("a","b"), l=N),
y = rnorm(N)
)[sample(.N)]
DF <- as.data.frame(DT)
},
seconds.limit=0.001,
frame=split(DF[names(DF) != "x1"], DF["x1"], drop = TRUE),
table=split(DT, by = "x1", keep.by = FALSE, drop = TRUE)
)
split.best <- atime::references_best(split.result)
plot(split.best)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.