View source: R/runBenchmarks.R

benchmarkRuntime | R Documentation |

Benchmark runtimes of several functions

```
benchmarkRuntime(createModel, evaluationFunctions, n)
```

`createModel` |
a function that creates and returns a fitted model. |

`evaluationFunctions` |
a list of functions that are to be evaluated on the fitted models. |

`n` |
number of replicates. |

This is a small helper function designed to benchmark runtimes of several operations that are to be performed on a list of fitted models. In the example, this is used to benchmark the runtimes of several DHARMa tests.

Florian Hartig

```
createModel = function(){
testData = createData(family = poisson(), overdispersion = 1,
randomEffectVariance = 0)
fittedModel <- glm(observedResponse ~ Environment1, data = testData, family = poisson())
return(fittedModel)
}
a = function(m){
testUniformity(m, plot = FALSE)$p.value
}
b = function(m){
testDispersion(m, plot = FALSE)$p.value
}
c = function(m){
testDispersion(m, plot = FALSE, type = "PearsonChisq")$p.value
}
evaluationFunctions = list(a,b, c)
benchmarkRuntime(createModel, evaluationFunctions, 2)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.