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.1.tar.gz (5.0 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.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for otime-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b4a9ef788330a0549d495922338d4694336877493fa9307498e1d86b7a0013e9
MD5 78b5084d9e15400ae97c40f337e8c7d2
BLAKE2b-256 d053a583cb85f3f2132a77561a0594b821ded0b0a6e6a1f89c053734dc55cab5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: otime-0.1.1-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

Hashes for otime-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a07f5cefe1b9d2794988392bf6990e4789fa6c57ea576a67216ebaec73d766b6
MD5 bd721637a07208e731c8405044f35af0
BLAKE2b-256 3524af45fbde3122c076f32ae01f899a96006ef19077eee809f635d14774690e

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