Skip to main content

Python library for tracking time and displaying progress bars

Project description

Chronometry

ProgressBar

Estimator

Estimator is an object that estimates the running time of a single argument function. You can use it to avoid running a script for too long. For example, if you want to cluster a large dataset and running it might take too long, and cost too much if you use cloud computing, you can create a function with one argument x which takes a sample with x rows and clusters it; then you can use Estimator to estimate how long it takes to run it on the full dataset by providing the actual number of rows to the estimate() method.

Estimator uses a Polynomial Linear Regression model and gives more weight to larger numbers for the training.

Usage

from chronometry import Estimator
from time import sleep

def multiply_with_no_delay(x, y):
    return (x ** 2 + 0.1 * x ** 3 + 1) * 0.00001 + y * 0.001

def multiply(x, y):
    sleep_time = multiply_with_no_delay(x, y)
    if sleep_time > 30:
        raise
    sleep(sleep_time)
    if y == 6:
        sleep(12)
    elif 7 < y < 15:
        raise Exception()
    return sleep_time

estimator = Estimator(function=multiply, polynomial_degree=3, timeout=5)
# the `unit` argument chooses the unit of time to be used. By default unit='s'

estimator.auto_explore()
estimator.predict_time(x=10000, y=10000)

The above code runs for about 53 seconds and then estimates that multiply(10000, 10000) will take 1002371.7 seconds which is only slightly smaller than the correct number: 1001010 seconds.

max_time is the maximum time allowed for the estimate function to run.

If you are using Estimator in Jupyter, you can plot the measurements with the plot() method (no arguments needed) which returns a matplotlib AxesSubplot object and displays it at the same time.

estimator.plot('x')

estimator.plot('y')

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

chronometry-2020.11.12.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

chronometry-2020.11.12-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file chronometry-2020.11.12.tar.gz.

File metadata

  • Download URL: chronometry-2020.11.12.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for chronometry-2020.11.12.tar.gz
Algorithm Hash digest
SHA256 21963aa633ee987503ac50b0f9f25286c80b7a326901ecaafeef33aa03b4ef10
MD5 19013d88934962e03d06f58ed8698d45
BLAKE2b-256 9315c445e164db7dcb2068653974931964433af911b17ece66f6923941ad3b3e

See more details on using hashes here.

File details

Details for the file chronometry-2020.11.12-py3-none-any.whl.

File metadata

  • Download URL: chronometry-2020.11.12-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for chronometry-2020.11.12-py3-none-any.whl
Algorithm Hash digest
SHA256 05bf584ff2dc16f53cd976cd38428be2491dd4bb30825a2063e4082738ed129d
MD5 20b8a0d8d3e883fb3bc6115d05f2fa24
BLAKE2b-256 8d84d4c0279b71df3c894b9ce89cffdc4d828c5cb3d05a4729e2c84a0a129e47

See more details on using hashes here.

Supported by

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