On 30 December 2016 at 06:37, Dirk Eddelbuettel wrote: | | On 29 December 2016 at 11:25, Jonathan Christensen wrote: | | Hi Kaspar and Dirk, | | | | It is indeed cumulative. Previously (presumably when that gallery page was | | written) it was not cumulative, but Romain Francois changed the behavior of the | | step() function several years ago, in this commit: https://github.com/RcppCore/ | | Rcpp/commit/e295b2b178de55291e63705966368404bb0ce5e1. | | Nice catch. | | | There is no indication or reasoning about changing the behavior, so it may be | | that making it cumulative was unintentional. | | Let's presume it was intentional to the author of the change -- but as you | rightly point out, it did of course change and reverse previous behaviour. | | We could easily add a toggle to the constructor to get an either/or behaviour.
Even easier: - Add a step() call immediately after creating timer() - This also records the start - Results are still cumulative - Running diff() over it shows changes: Demo using minimally modified Rcpp Gallery piece (just added step("start"); ) R> sourceCpp("/tmp/timer.cpp") R> tt <- useTimer() R> tt # cumulative start get/put g/p+rnorm() empty loop 0.000114 1629.043000 3996.890739 3996.893329 R> diff(tt) # incremental get/put g/p+rnorm() empty loop 1629.04289 2367.84774 0.00259 R> I will alter the gallery story accordingly. We can always add a 'zero' step to the constructor to get these two behaviours cheaply. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel