[Rcpp-commits] r2333 - pkg/RcppDE
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Oct 18 20:37:32 CEST 2010
Author: edd
Date: 2010-10-18 20:37:32 +0200 (Mon, 18 Oct 2010)
New Revision: 2333
Modified:
pkg/RcppDE/benchmark.r
pkg/RcppDE/bigBenchmark.r
Log:
move sanity-check comparison outside of timing function
Modified: pkg/RcppDE/benchmark.r
===================================================================
--- pkg/RcppDE/benchmark.r 2010-10-18 18:23:33 UTC (rev 2332)
+++ pkg/RcppDE/benchmark.r 2010-10-18 18:37:32 UTC (rev 2333)
@@ -23,14 +23,14 @@
cppDE <- function(n, maxIt, fun) RcppDE::DEoptim(fn=fun, lower=rep(-25, n), upper=rep(25, n),
control=list(NP=10*n, itermax=maxIt, trace=FALSE))
+set.seed(42)
+valBasic <- basicDE(5, maxIt, fun)
+set.seed(42)
+valCpp <- cppDE(5, maxIt, fun)
+stopifnot( all.equal(valBasic, valCpp) )
+
runPair <- function(n, maxIt, fun) {
- set.seed(42)
- valBasic <- basicDE(n, maxIt, fun)
- set.seed(42)
- valCpp <- cppDE(n, maxIt, fun)
- stopifnot( all.equal(valBasic, valCpp) )
-
gc()
set.seed(42)
bt <- mean(replicate(10, system.time(invisible(basicDE(n, maxIt, fun)))[3]), trim=0.1)
Modified: pkg/RcppDE/bigBenchmark.r
===================================================================
--- pkg/RcppDE/bigBenchmark.r 2010-10-18 18:23:33 UTC (rev 2332)
+++ pkg/RcppDE/bigBenchmark.r 2010-10-18 18:37:32 UTC (rev 2333)
@@ -23,16 +23,13 @@
cppDE <- function(n, maxIt, fun) RcppDE::DEoptim(fn=fun, lower=rep(-25, n), upper=rep(25, n),
control=list(NP=10*n, itermax=maxIt, trace=FALSE))#, bs=TRUE))
-runPair <- function(n, maxIt, fun) {
+set.seed(42)
+valBasic <- basicDE(5, maxIt, fun)
+set.seed(42)
+valCpp <- cppDE(5, maxIt, fun)
+stopifnot( all.equal(valBasic, valCpp) )
- set.seed(42)
- valBasic <- basicDE(n, maxIt, fun)
- #print(str(valBasic))
- set.seed(42)
- valCpp <- cppDE(n, maxIt, fun)
- #print(str(valCpp))
- stopifnot( all.equal(valBasic, valCpp) )
-
+runPair <- function(n, maxIt, fun) {
gc()
set.seed(42)
bt <- system.time(invisible(basicDE(n, maxIt, fun)))[3]
More information about the Rcpp-commits
mailing list