[Paper Review] GuessCompx: An empirical complexity estimation in R.
GuessCompx is an R package that empirically estimates time and memory complexity of algorithms or functions by testing increasing data sizes and fitting them to seven standard complexity models (e.g., O(N), O(N²)) using LOO-MSE. It predicts full dataset performance and returns significance tests and plots, enabling complexity analysis without requiring access to the target function's source code.
This article introduces GuessCompx which is an R package that performs an empirical estimation on the time and memory complexities of an algorithm or a function. It tests multiple increasing-sizes samples of the user's data and attempts to fit one of seven complexity functions: O(N), O(N^2), O(log(N)), etc. Based on a best fit procedure using LOO-MSE (leave one out-mean squared error), it also predicts the full computation time and memory usage on the whole dataset. Conceptually, it relies on the base R functions system.time and memory.size, the latter being only suitable for Windows users. Together with this results, a plot and a significance test are returned. Complexity is assessed with regard to the user's actual dataset through its size (and no other parameter). This article provides several examples demonstrating several cases (e.g., distance function, time series and custom function) and optimal parameters tuning. The subject of the empirical computational complexity has been relatively little studied in computer sciences, and such a package provides a reliable, convenient and simple procedure for estimation process. Further, the package does not require to have the code of the target function.
Motivation & Objective
- To address the underexplored area of empirical computational complexity estimation in computer science.
- To provide a reliable, user-friendly method for estimating time and memory complexity without requiring access to the target function's source code.
- To enable researchers and practitioners to predict full dataset performance (time and memory usage) based on empirical profiling.
- To support complexity analysis across diverse use cases, such as distance functions, time series, and custom functions.
- To offer a simple, automated procedure for complexity estimation using standard R functions and statistical fitting.
Proposed method
- Empirically measures execution time and memory usage using base R functions system.time and memory.size (Windows-only).
- Executes the target function on multiple increasing-sized samples of the user's dataset.
- Fits the observed performance data to seven candidate complexity models (e.g., O(N), O(N²), O(log N)) using LOO-MSE (leave-one-out mean squared error).
- Selects the best-fitting complexity model based on minimal LOO-MSE across all candidates.
- Generates a significance test and a visualization plot to assess model fit and complexity trends.
- Predicts full dataset time and memory usage based on the best-fit model.
Experimental results
Research questions
- RQ1What is the empirical time complexity of a given function when executed on increasing data sizes?
- RQ2What is the empirical memory complexity of a function, and how does it scale with input size?
- RQ3Which of seven standard complexity models (e.g., O(N), O(N²)) best fits the observed performance behavior?
- RQ4Can full dataset execution time and memory usage be reliably predicted from small-scale measurements?
- RQ5How robust and accurate is the LOO-MSE-based model selection in identifying true algorithmic complexity?
Key findings
- GuessCompx successfully identifies the best-fitting complexity model (e.g., O(N), O(N²)) using LOO-MSE across diverse test cases.
- The package enables prediction of full dataset execution time and memory usage based on empirical profiling.
- The method provides a significance test to assess the reliability of the fitted complexity model.
- The approach works without requiring access to the source code of the target function, enhancing usability.
- The package supports practical use across various domains, including distance computation, time series analysis, and custom functions.
- Empirical results demonstrate that the method reliably estimates complexity using only runtime and memory measurements on increasing data sizes.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.