View source: R/expect_linear_time.R
expect_linear_time | R Documentation |
Function to test if input algorithm has linear time complexity
expect_linear_time(...)
... |
Parameters for the expression to be tested, which is a function of data.sizes, as in asymptoticTimings |
For more information regarding its implementation or functionality/usage, please check https://anirban166.github.io//Testing-functions/
null for expected complexity (linear), else throws error.
## Not run:
# Running the quick sort algorithm with sampling against a set of increasing input data sizes:
sizes = 10^seq(1, 3, by = 0.5)
expect_linear_time(sort(sample(1:100, data.sizes, replace = TRUE), method = "quick"), sizes)
# The code above will throw an error if the function does not follow a linear trend.
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.