A package for analyzing time complexity of functions
Project description
OTime: Time Complexity Analyzer
A Python package for empirically analyzing the time complexity of functions.
Installation
pip install otime
Usage
from otime import analyze_time_complexity
def my_function(data):
# Your function here
pass
sizes = [100, 200, 400, 800, 1600]
complexity, r_squared = analyze_time_complexity(
my_function,
lambda x: list(range(x)), # Input generator
sizes
)
print(f"Time complexity: {complexity}")
print(f"R-squared: {r_squared}")
More examples
from otime import analyze_time_complexity
# Example usage
def example_input_generator(size):
"""Generate a list of given size for testing."""
return size
def func(n):
for i in range(n):
j = i * i
while j > 0:
j //= 4
sizes = [100, 200, 400, 800, 1600, 3200]
complexity, r_squared = analyze_time_complexity(
func,
example_input_generator,
sizes,
save_plot=True
)
print(f"Results:")
print(f"Detected time complexity: {complexity}")
print(f"R-squared value: {r_squared:.4f}")
Features
- Automatic time complexity detection
- Visual plotting of results
- Support for common complexity classes
- Robust numerical analysis
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
otime-0.1.2.tar.gz
(5.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
otime-0.1.2-py3-none-any.whl
(5.1 kB
view details)
File details
Details for the file otime-0.1.2.tar.gz.
File metadata
- Download URL: otime-0.1.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61163002900c643b4ee90d157c911a03fe2bd44c4a0bcec62006d18104325634
|
|
| MD5 |
9a19eebe53a8f063b53b416f7d3b7a59
|
|
| BLAKE2b-256 |
08920d246c3118acd462f7ce9fe689e8988dc4eb44638bec619b81290850089b
|
File details
Details for the file otime-0.1.2-py3-none-any.whl.
File metadata
- Download URL: otime-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95f3eed47d5e1501d179c2dfda3d419245cd7a6b03c0b4faa47dc72c702ed933
|
|
| MD5 |
cce45e3084ad8b069ed00d11c76f08c2
|
|
| BLAKE2b-256 |
cc1a9b7292b6e628b49419980ca162faf4fd2e3bad7873d4a0a5dada802bd55d
|