Skip to main content

Helper class to time python processes

Project description

time_utils

Basic python package to time processes similar to a stopwatch. This package also includes various pre-formated timestamps for sql, s3 key prefixes, and s3 glues prefixes.

stopWatch

A class intended to minimic the functionality of a stop watch. The lap function will return a human readable string of how much total time was elapsed as well as the lap time.

basic usage:

>>> from time_utils import time_utils as tu
>>> sw = tu.stopWatch()
>>> sw.lap()
Total Time:
4 second(s)

Lap 1:
4 second(s)

datetime.timedelta(seconds=4, microseconds=218298)
>>> sw.lap()
Total Time:
15 second(s)

Lap 2:
11 second(s)

datetime.timedelta(seconds=11, microseconds=440822)

preformatted datetime outputs

All functions default to utcnow(), however a datetime object can be passed in to any function.

ts_dict

>>> tu.time_utils.ts_dict()
{
'year': '2019', 
'month': '12', 
'day': '29', 
'hour': '00', 
'min': '24', 
'sec': '43'
}

sql_ts

>>> tu.time_utils.sql_ts()
'2019-12-29 00:25:00'

s3_ts

>>> tu.time_utils.s3_ts()
'/2019/12/29/'

s3_glue_ts

>>> tu.time_utils.s3_glue_ts()
'/year=2019/month=12/day=29/'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for time-utils, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size time_utils-1.0.1-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size time_utils-1.0.1.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page