Rperform: Obtaining quantitative metrics across R package versions
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
After almost a month since the start of the official coding period, the package Rperform is now ready with its initial suite of functions. Building on the proof-of-concept code provide by Toby Dylan Hocking, my mentor, I have written a set of functions for obtaining and plotting time metrics for individual test files over subsequent git versions, and obtain and plot time metrics for files across two given branches. This part had been relatively easy and straight-forward as compared to obtaining the memory metrics, which are work-in-progress at the moment.
The memory metrics posed an issue due to the memory management methodology of R (involving gc()
) which didn’t allow for accurate capture of the memory in use at a particular point of time. However, with Toby’s help and some insights from Hadley, I have been able to obtain the memory metrics for individual test files. The trick was to start a new process through the command-line for each individual commit rather than try to obtain them through the current R process. The code for obtaining memory usage for individual testthat blocks within the files is still being worked out.
The examples for some of the functions from the package are given below.
The following example illustrates the use of the Rperform::plot_time()
function on the git repository
of the package stringr.
> setwd("~/stringr") > library(Rperform) > get_times(test_path = "./tests/testthat/test-extract.r", num_commits = 10)
The following example illustrates the use of Rperform::mem_compare()
on a test file from the package, PeakSegJoint
> setwd("~/PeakSegJoint") > Rperform::mem_compare(test_path = "./tests/testthat/test-likelihood.R", num_commits = 5)
> setwd("~/stringr") > Rperform::plot_btimes(test_path = "./tests/testthat/test-extract.r", branch1 = "stringi", branch2 = "master")
The vertical line divides the results from branch1 commits and branch2 commits, with the former being on the left hand side. In the above example, there existed only one commit in branch1 after the latest common commit.
Next set of targets include completion of memory functionality, writing an initial set of tests and integration with the Travis-CI build system among other things.
The package in its current form can be found on Github (Rperform).
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.