[Rcpp-commits] r2076 - in pkg/Rcpp: . inst inst/examples/ConvolveBenchmarks
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 7 03:04:24 CEST 2010
Author: edd
Date: 2010-09-07 03:04:24 +0200 (Tue, 07 Sep 2010)
New Revision: 2076
Modified:
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/inst/ChangeLog
pkg/Rcpp/inst/examples/ConvolveBenchmarks/exampleRCode.r
Log:
rewritten ConvolveBenchmarks in terms of rbenchmark
added rbenchmark to Suggests
increased sub-minor release
updated ChangeLog for small changes over last few days
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2010-09-04 17:18:41 UTC (rev 2075)
+++ pkg/Rcpp/DESCRIPTION 2010-09-07 01:04:24 UTC (rev 2076)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Seamless R and C++ Integration
-Version: 0.8.5.9
+Version: 0.8.5.10
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, with contributions
by Simon Urbanek, David Reiss and Douglas Bates; based on code written during
@@ -34,7 +34,7 @@
Several examples are included, and 735 unit tests in 329 unit test functions
provide additional usage examples.
Depends: R (>= 2.10.0), methods
-Suggests: RUnit, inline, highlight
+Suggests: RUnit, inline, highlight, rbenchmark
URL: http://dirk.eddelbuettel.com/code/rcpp.html, http://romainfrancois.blog.free.fr/index.php?category/R-package/Rcpp
License: GPL (>= 2)
BugReports: http://r-forge.r-project.org/tracker/?atid=637&group_id=155&func=browse
Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog 2010-09-04 17:18:41 UTC (rev 2075)
+++ pkg/Rcpp/inst/ChangeLog 2010-09-07 01:04:24 UTC (rev 2076)
@@ -1,3 +1,32 @@
+2010-09-06 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/examples/ConvolveBenchmarks/exampleRCode.r: Rewritten /
+ simplified using the rbenchmark::benchmark() function
+ * DESCRIPTION: Added Suggests: on rbenchmark package
+
+2010-09-04 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/examples/ConvolveBenchmarks/exampleRCode.r: Some cosmetics
+
+ * inst/examples/ConvolveBenchmarks/convolve3_cpp.cpp: Remove one
+ unneccessary loop to set values to zero (which the ctor does for us)
+
+2010-09-03 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/doc/Rcpp-extending/Rcpp-extending.Rnw: Add highlight definitions
+ * inst/doc/Rcpp-FAQ/Rcpp-FAQ.Rnw: Idem
+ * inst/doc/Rcpp-package/Rcpp-package.Rnw: Idem
+
+2010-09-02 Dirk Eddelbuettel <edd at debian.org>
+
+ * src/msvcmath.cpp: Undo unmotivated msvc patch
+ * inst/include/Rcpp/msvc/: Idem
+ * inst/include/Rcpp/XPtr.h: Idem
+ * inst/include/RcppCommon.h: Idem
+ * src/Date.cpp: Idem
+
+ * DESCRIPTION: Added Suggests: on highlight package
+
2010-08-20 Romain Francois <romain at r-enthusiasts.com>
* inst/include/Rcpp/complex.h : binary operators for Rcomplex : +,-,*,/
@@ -4,11 +33,11 @@
2010-08-15 Romain Francois <romain at r-enthusiasts.com>
- * inst/include/Rcpp/sugar/SugarBlock.h: more control of the NA behavior
+ * inst/include/Rcpp/sugar/SugarBlock.h: more control of the NA behavior
in SUGAR_BLOCK_2. SUGAR_BLOCK_2 will now propagate the NA, and the new
SUGAR_BLOCK_2_NA will use a fixed NA (can be true or false). This can be
useful if the function that is sugar'ed never generates NA.
-
+
* inst/include/Rcpp/sugar/undoRmath.h : undo the macros done by Rmath.h
2010-08-13 Douglas Bates <bates at stat.wisc.edu>
Modified: pkg/Rcpp/inst/examples/ConvolveBenchmarks/exampleRCode.r
===================================================================
--- pkg/Rcpp/inst/examples/ConvolveBenchmarks/exampleRCode.r 2010-09-04 17:18:41 UTC (rev 2075)
+++ pkg/Rcpp/inst/examples/ConvolveBenchmarks/exampleRCode.r 2010-09-07 01:04:24 UTC (rev 2076)
@@ -4,64 +4,51 @@
a <- rnorm(100)
b <- rnorm(100)
-## load shared library with wrapper code and callback class
+## load shared libraries with wrapper code
dyn.load("convolve2_c.so")
+dyn.load("convolve2_cpp.so")
+dyn.load("convolve3_cpp.so")
+dyn.load("convolve4_cpp.so")
+dyn.load("convolve5_cpp.so")
+dyn.load("convolve7_c.so")
-## call the wrapper function provided in the shared library
+## now run each one once for comparison of results,
+## and define test functions
+
v1 <- .Call("convolve2", a, b)
-t1 <- system.time(replicate(1000, .Call("convolve2", a, b)))
+R_API_optimised <- function(a,b) .Call("convolve2", a, b)
-
-## load shared library with wrapper code and callback class
-dyn.load("convolve2_cpp.so")
-
-## call the wrapper function provided in the shared library
v2 <- .Call("convolve2cpp", a, b)[[1]]
-t2 <- system.time(replicate(1000, .Call("convolve2cpp", a, b)))
+stopifnot(all.equal(v1, v2))
+RcppClassic <- function(a,b) .Call("convolve2cpp", a, b)
-
-## load shared library with wrapper code and callback class
-dyn.load("convolve3_cpp.so")
-
-## call the wrapper function provided in the shared library
v3 <- .Call("convolve3cpp", a, b)
-t3 <- system.time(replicate(1000, .Call("convolve3cpp", a, b)))
+stopifnot(all.equal(v1, v3))
+RcppNew_std <- function(a,b) .Call("convolve3cpp", a, b)
-
-## load shared library with wrapper code and callback class
-dyn.load("convolve4_cpp.so")
-
-## call the wrapper function provided in the shared library
v4 <- .Call("convolve4cpp", a, b)
-t4 <- system.time(replicate(1000, .Call("convolve4cpp", a, b)))
+stopifnot(all.equal(v1, v4))
+RcppNew_ptrs <- function(a,b) .Call("convolve4cpp", a, b)
-
-## load the sugar based version
-dyn.load( "convolve5_cpp.so" )
v5 <- .Call( "convolve5cpp", a, b )
-t5 <- system.time(replicate(1000, .Call("convolve5cpp", a, b)))
+stopifnot(all.equal(v1, v5))
+RcppNew_sugar <- function(a,b) .Call("convolve5cpp", a, b)
-
-## load shared library with wrapper code and callback class
-dyn.load("convolve7_c.so")
-
-## call the wrapper function provided in the shared library
v7 <- .Call("convolve7", a, b)
-t7 <- system.time(replicate(1000, .Call("convolve7", a, b)))
+R_API_naive <- function(a,b) .Call("convolve7", a, b)
+## load benchmarkin helper function
+suppressMessages(library(rbenchmark))
+bm <- benchmark(R_API_optimised(a,b),
+ R_API_naive(a,b),
+ RcppClassic(a,b),
+ RcppNew_std(a,b),
+ RcppNew_ptrs(a,b),
+ RcppNew_sugar(a,b),
+ columns=c("test", "replications", "elapsed", "relative", "user.self", "sys.self"),
+ order="relative",
+ replications=10000)
+print(bm)
-res <- data.frame(rbind(t1, t7, t2, t3, t4, t5))
-rownames(res) <- c("Writing R extensions -- pointer arithm.",
- "Writing R extensions -- using [] acess",
- "RcppVector<double>::operator()",
- "Rcpp::NumericVector::operator[]",
- "Rcpp::NumericVector::begin()",
- "sugar" )
-print(res[,1:3])
-
-results <- list( v1, v2, v3, v4, v7, v5)
-for (i in seq_along(results) ){
- stopifnot( all.equal(results[[1L]], results[[i]] ) )
-}
cat("All results are equal\n") # as we didn't get stopped
More information about the Rcpp-commits
mailing list