[Rcpp-devel] min, max, range

Hadley Wickham h.wickham at gmail.com
Thu Nov 15 19:35:06 CET 2012


You can make the differences more profound if you choose examples
where range.default does really badly (assuming your implementation is
similar to my attached implementation)

                   expr  min   lq median   uq   max neval
 range(x, na.rm = TRUE) 1920 2488   2951 3349 23306   100
   min(x, na.rm = TRUE)  251  252    259  266   301   100
   max(x, na.rm = TRUE)  251  251    258  267   301   100
        range2(x, TRUE)  149  150    156  162   185   100
        range3(x, TRUE)  153  155    160  170   224   100
       range3a(x, TRUE)  462  465    477  492   794   100

Unit: microseconds
                    expr    min     lq median     uq     max neval
 range(x, na.rm = FALSE) 695.16 703.54 722.01 947.89 1875.59   100
   min(x, na.rm = FALSE) 251.10 251.26 251.49 262.27  581.50   100
   max(x, na.rm = FALSE) 251.11 251.27 251.56 258.65  329.30   100
        range2(x, FALSE)   1.42   1.75   2.11   3.27    6.48   100
        range3(x, FALSE)   1.39   1.67   2.13   2.90   16.42   100
       range3a(x, FALSE)   1.42   1.80   2.33   2.98   21.32   100

Hadley


-- 
RStudio / Rice University
http://had.co.nz/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: range.r
Type: application/octet-stream
Size: 404 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121115/b760285c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: range.cpp
Type: text/x-c++src
Size: 1495 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121115/b760285c/attachment.cpp>


More information about the Rcpp-devel mailing list