Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
When discussing how to speed up slow R code, my first question is what is your computer spec? It always surprises me when complex biological experiments, costing a significant amount of money, are analysed using a six year old laptop. A new desktop machine costs around £1000 and that money would be saved within a month in user time. Typically the more the RAM you have, the larger the dataset you can handle. However it’s not so obvious of the benefit of upgrading the processor.
To quantify the impact of the CPU on an analysis, I created the package benchmarkme. The aim of this package is to provide a set of benchmarks routines and data from past runs. You can then compare your machine, with other CPUs.
The package is now on CRAN and can be installed in the usual way
install.packages("benchmarkme")
The benchmark_std() function assesses numerical operations such as loops and matrix operations. This benchmark comprises of three separate benchmarks: prog, matrix_fun, and matrix_cal. If you have less than 3GB of RAM (run `get_ram()` to find out how much is available on your system), then you should kill any memory hungry applications, e.g. firefox, and set `runs = 1` as an argument.
To benchmark your system, use
library("benchmarkme") res = benchmark_std(runs = 3)
You can compare your results to other users via
plot(res)
My laptop is ranked around 50 out of 300. However, relative to the fastest processor, there’s not much difference.
Finally upload your results for the benefit of other users
## You can control exactly what is uploaded. See details below. upload_results(res)
Shiny
You can also compare your results using the Shiny interface. Simply create a results bundle
create_bundle(res, filename = "results.rds")
and upload to the webpage.
What’s uploaded
Two objects are uploaded:
1. Your benchmarks from benchmark_std or benchmark_io;
2. A summary of your system information (get_sys_details()).
The get_sys_details() returns:
– Sys.info();
– get_platform_info();
– get_r_version();
– get_ram();
– get_cpu();
– get_byte_compiler();
– get_linear_algebra();
– installed.packages();
– Sys.getlocale();
– The `benchmarkme` version number;
– Unique ID – used to extract results;
– The current date.
The function Sys.info() does include the user and nodenames. In the public release of the data, this information will be removed. If you don’t wish to upload certain information, just set the corresponding argument, i.e.
upload_results(res, args = list(sys_info=FALSE))
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.