Bigocheck is a zero-dependency empirical Big-O complexity checker for Python, designed for both library and command-line use. It allows for measuring runtimes across varying input sizes and fitting results against standard complexity classes. Perfect for developers seeking to track complexity regressions with ease.
bigocheck is a powerful, zero-dependency empirical complexity checker designed for Python developers. It allows users to empirically measure the time and space complexity of functions via command line interface (CLI), assertions, and integration with pytest. The tool efficiently runs a target function across various input sizes, records runtimes, and fits the results against well-known complexity classes. This dual approach as a library and command-line tool makes it versatile for development and testing workflows.
pip install bigocheck
To benchmark a function, simply run:
bigocheck run --target mymodule:myfunc --sizes 100 500 1000 --trials 3
For library usage:
from bigocheck import benchmark_function
def my_func(n):
return sum(range(n))
analysis = benchmark_function(my_func, sizes=[100, 500, 1000])
print(f"Best fit: {analysis.best_label}") # 'O(n)'
For visually appealing reports, one can generate HTML reports:
generate_html_report(analysis, title="Function Analysis")
bigocheck also includes several core functions and classes, designed to streamline your benchmarking process. Key functions include benchmark_function, fit_complexities, and compare_functions. These additions simplify integration and allow customization for advanced tasks.
With its comprehensive features and focus on performance measurement without external dependencies, bigocheck is an essential tool for Python developers aiming to optimize code performance and maintain high standards in software development.
No comments yet.
Sign in to be the first to comment.