R package developers currently use ad-hoc tests of asymptotic computational complexity via empirical timings of functions and visual diagnostic plots. However, there is no framework in R for systematically testing the empirical computational complexity of functions, which tends to be a problem because such a testing framework could be essential for identifying big speed gains in R code as well. In response to improve the stated, this project brings a new package 'testComplexity', which provides a suite of functions that will be useful for testing and thereby improving the speed (via code optimization) of various algorithms/functions in R. It quantifies the runtimes for an algorithm, classifies its time complexity trend, tests for an expected complexity class and plots the benchmarked results to help visually conceive the results. Additionally, other features such as quantifying memory allocations, subsequently predicting the space complexity class and classifying complexity for user-defined output parameters (apart from time/memory cases) have been implemented. Since algorithms are used in every sphere of research, this package potentially caters to all types of R-users.


Anirban Chetia


  • Toby Hocking
  • Neeraj Dhanraj Bokde