Re: [Rd] Benchmark code, but avoid printing
Yes, thanks much, this makes a lot of sense. Well, by "better" what I had in mind was something that is reliably close to the time needed for printing. Without actually doing the printing. But I realize this is too much to ask for, and I'll be fine with /dev/null. Thanks for bringing up the textConnection() issue as well, especially because I am using textConnection now. /dev/null is a better option. Best, Gabor On Fri, Jan 2, 2015 at 3:44 PM, Simon Urbanek wrote: > On Jan 2, 2015, at 12:02 PM, Gábor Csárdi wrote: > >> Dear all, >> >> I am trying to benchmark code that occasionally prints on the screen >> and I want to >> suppress the printing. Is there an idiom for this? >> >> If I do >> >> sink(tempfile) >> microbenchmark(...) >> sink() >> >> then I'll be also measuring the costs of writing to tempfile. I could >> also sink to /dev/null, which is probably fast, but that is not >> portable. >> >> Is there a better solution? Is writing to a textConnection() better? >> > > Define better - you're just trading off one output code for another - it will > be still measuring the cost of the output, obviously, and since the output is > part of the code you're profiling it's correctly so. Each output method has > different beavior - e.g. text connection can be faster, but it can also > trigger additional garbage collection so it will affect results. Example: > >> f=textConnection("x", "w") >> sink(f) >> m=microbenchmark({ for (i in 1:100) { print("foo"); sum(rnorm(1e3)) } }) >> sink() >> m > Unit: milliseconds > > expr > { for (i in 1:100) { print("foo") sum(rnorm(1000)) } > } > min lq mean median uq max neval > 12.76462 15.34483 17.85341 17.02435 19.56384 63.09329 100 >> sink("/dev/null") >> m=microbenchmark({ for (i in 1:100) { print("foo"); sum(rnorm(1e3)) } }) >> sink() >> m > Unit: milliseconds > > expr > { for (i in 1:100) { print("foo") sum(rnorm(1000)) } > } > min lq mean median uq max neval > 13.0191 13.03601 13.41815 13.0534 13.16496 16.25288 100 > > As you can see /dev/null is more predictable, because it's straight output, > but text connection can be faster in the beginning and becomes progressively > slower. > > As Henrik said, you're probably best off using simply /dev/null - the only > oddball is Windows, and that's a trivial condition on .Platform$OS.type. > > Cheers, > S > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Help in building R with minGW
Please read R-admin section 3.1 - as you'll notice it doesn't say anything about running ./configure since that's only for unix. http://r.research.att.com/man/R-admin.html#Building-from-source Cheers, Simon On Jan 2, 2015, at 12:33 PM, Edoardo Baldoni wrote: > Dear R users, > I would need some help in building R using minGW in windows 8.1. After > using the command *configure *(./configure --enable-R-shlib > --with-readline=no --with-x=no), I use the command *make. *This results in > the following error: > > [...] > make[2]: Leaving directory `/home/Edoardo/r-3.1.2/src/nmath' > make[2]: Entering directory `/home/Edoardo/r-3.1.2/src/unix' > make[3]: Entering directory `/home/Edoardo/r-3.1.2/src/unix' > gcc -std=gnu99 -I. -I../../src/include -I../../src/include > -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c dynload.c -o dynload.o > dynload.c: In function 'Rf_InitFunctionHashing': > dynload.c:69:32: warning: assignment from incompatible pointer type > [enabled by default] > R_osDynSymbol->loadLibrary = loadLibrary; >^ > dynload.c:71:33: warning: assignment from incompatible pointer type > [enabled by default] > R_osDynSymbol->closeLibrary = closeLibrary; > ^ > dynload.c: At top level: > dynload.c:97:13: error: conflicting types for 'closeLibrary' > static void closeLibrary(HINSTANCE handle) > ^ > dynload.c:59:13: note: previous declaration of 'closeLibrary' was here > static void closeLibrary(void *handle); > ^ > dynload.c:59:13: warning: 'closeLibrary' used but never defined [enabled by > default] > make[3]: *** [dynload.o] Error 1 > make[3]: Leaving directory `/home/Edoardo/r-3.1.2/src/unix' > make[2]: *** [R] Error 2 > make[2]: Leaving directory `/home/Edoardo/r-3.1.2/src/unix' > make[1]: *** [R] Error 1 > make[1]: Leaving directory `/home/Edoardo/r-3.1.2/src' > make: *** [R] Error 1 > > > I am not an expert programmer and would appreciate some help. My final > objective is to install R as shared library in order to use RHIPE. > Thanks > > Edoardo > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Benchmark code, but avoid printing
On Jan 2, 2015, at 12:02 PM, Gábor Csárdi wrote: > Dear all, > > I am trying to benchmark code that occasionally prints on the screen > and I want to > suppress the printing. Is there an idiom for this? > > If I do > > sink(tempfile) > microbenchmark(...) > sink() > > then I'll be also measuring the costs of writing to tempfile. I could > also sink to /dev/null, which is probably fast, but that is not > portable. > > Is there a better solution? Is writing to a textConnection() better? > Define better - you're just trading off one output code for another - it will be still measuring the cost of the output, obviously, and since the output is part of the code you're profiling it's correctly so. Each output method has different beavior - e.g. text connection can be faster, but it can also trigger additional garbage collection so it will affect results. Example: > f=textConnection("x", "w") > sink(f) > m=microbenchmark({ for (i in 1:100) { print("foo"); sum(rnorm(1e3)) } }) > sink() > m Unit: milliseconds expr { for (i in 1:100) { print("foo") sum(rnorm(1000)) } } min lq mean median uq max neval 12.76462 15.34483 17.85341 17.02435 19.56384 63.09329 100 > sink("/dev/null") > m=microbenchmark({ for (i in 1:100) { print("foo"); sum(rnorm(1e3)) } }) > sink() > m Unit: milliseconds expr { for (i in 1:100) { print("foo") sum(rnorm(1000)) } } min lq mean median uq max neval 13.0191 13.03601 13.41815 13.0534 13.16496 16.25288 100 As you can see /dev/null is more predictable, because it's straight output, but text connection can be faster in the beginning and becomes progressively slower. As Henrik said, you're probably best off using simply /dev/null - the only oddball is Windows, and that's a trivial condition on .Platform$OS.type. Cheers, S __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Benchmark code, but avoid printing
On Fri, Jan 2, 2015 at 9:02 AM, Gábor Csárdi wrote: > Dear all, > > I am trying to benchmark code that occasionally prints on the screen > and I want to > suppress the printing. Is there an idiom for this? > > If I do > > sink(tempfile) > microbenchmark(...) > sink() > > then I'll be also measuring the costs of writing to tempfile. I could > also sink to /dev/null, which is probably fast, but that is not > portable. Interesting problem. On Windows NUL corresponds to /dev/NULL, e.g. con <- file("NUL", open="wb"). Not that it's cross platform, but it at least allows you to cover on more OS. Maybe R should have a built-in "null" device. An easier solution is probably to go back to the maintainers of the functions outputting text and ask them for an option to disable that. > > Is there a better solution? Is writing to a textConnection() better? For large number of output *lines* (not characters), textConnection() is exponentially slow (at least in R 3.1.0). Use rawConnection() instead, cf. http://www.jottr.org/2014/05/captureOutput.html /Henrik > > Thanks, Best, > Gabor > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Reimplement stats:::plotNode as iterative to avoid recursion limits?
> Gregory R Warnes > on Thu, 1 Jan 2015 18:35:23 -0500 writes: > Hi All, I've gotten a number of reports from users > about gplots::heatmap.2 generating 'node stack > overflow' errors. As it turns out, these errors > originate in stats:::plotNode, and are triggered when > it is passed a dendrogram that is too deeply nested. > While increasing the stack size (which is a > compile-time option for byte coded functions) can > allow a particular instance to succeed, a better > solution would be to modify stats:::plotNode to use a > recursive, rather than iterative algorithm. of course you mean the contrary: reprogram stats:::plotNode() to use a *non*-recursive algorithm {"iterative" as you say in the 'Subject' line} > Anyone want to take this up as a programming > challenge? Yes, please, patches are very welcome -- if they are tested. Please start from https://svn.r-project.org/R/trunk/src/library/stats/R/dendrogram.R i.e. send patches with respect to that, i.e., the result of diff -ubBw .R .R With thanks in advance, Martin Maechler __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Help in building R with minGW
Dear R users, I would need some help in building R using minGW in windows 8.1. After using the command *configure *(./configure --enable-R-shlib --with-readline=no --with-x=no), I use the command *make. *This results in the following error: [...] make[2]: Leaving directory `/home/Edoardo/r-3.1.2/src/nmath' make[2]: Entering directory `/home/Edoardo/r-3.1.2/src/unix' make[3]: Entering directory `/home/Edoardo/r-3.1.2/src/unix' gcc -std=gnu99 -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c dynload.c -o dynload.o dynload.c: In function 'Rf_InitFunctionHashing': dynload.c:69:32: warning: assignment from incompatible pointer type [enabled by default] R_osDynSymbol->loadLibrary = loadLibrary; ^ dynload.c:71:33: warning: assignment from incompatible pointer type [enabled by default] R_osDynSymbol->closeLibrary = closeLibrary; ^ dynload.c: At top level: dynload.c:97:13: error: conflicting types for 'closeLibrary' static void closeLibrary(HINSTANCE handle) ^ dynload.c:59:13: note: previous declaration of 'closeLibrary' was here static void closeLibrary(void *handle); ^ dynload.c:59:13: warning: 'closeLibrary' used but never defined [enabled by default] make[3]: *** [dynload.o] Error 1 make[3]: Leaving directory `/home/Edoardo/r-3.1.2/src/unix' make[2]: *** [R] Error 2 make[2]: Leaving directory `/home/Edoardo/r-3.1.2/src/unix' make[1]: *** [R] Error 1 make[1]: Leaving directory `/home/Edoardo/r-3.1.2/src' make: *** [R] Error 1 I am not an expert programmer and would appreciate some help. My final objective is to install R as shared library in order to use RHIPE. Thanks Edoardo [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Benchmark code, but avoid printing
Dear all, I am trying to benchmark code that occasionally prints on the screen and I want to suppress the printing. Is there an idiom for this? If I do sink(tempfile) microbenchmark(...) sink() then I'll be also measuring the costs of writing to tempfile. I could also sink to /dev/null, which is probably fast, but that is not portable. Is there a better solution? Is writing to a textConnection() better? Thanks, Best, Gabor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel