Skip to main content

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"\nResults:")
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


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.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

otime-0.1.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file otime-0.1.3.tar.gz.

File metadata

  • Download URL: otime-0.1.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for otime-0.1.3.tar.gz
Algorithm Hash digest
SHA256 21838587f58407df2602ad9c02340e916d0f788d201d0f2c4d6cbdf7ed288f7c
MD5 f6abb07a7c0155aec2241fb9dfa1862a
BLAKE2b-256 3857d3134dc6c154a5099f522eeab487e0f4316aab23a881fe00b39b8be3174e

See more details on using hashes here.

File details

Details for the file otime-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: otime-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for otime-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 153017870271fcdb0289435e0c313e2c5a5f627221503c1f7de7b64256b3e892
MD5 4eb442e3347a245f7414969c9431334a
BLAKE2b-256 e79d8ff75ecd694b857019e42742d041ada9d08862aeb4e398ef6a15a45d988c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page