Skip to main content

marktime.py

Simple python module for mark time.

Inspired by two functions from node.js:

Main features:

  • easy to use

  • no external dependencies

  • 100% test coverage

  • works with Python 2.7 and 3.3

Usage

$ pip install marktime
import marktime

marktime.start('some task')
marktime.start('some another task')

marktime.stop('some task')
8.757422924041748

marktime.stop('some another task').seconds
14.805735111236572

marktime.duration('some another task').msecs
14805.735111236572

marktime.start('some task # 3')

with marktime.stopwatch('some task # 4'):
    marktime.time.sleep(1)

import json
print json.dumps(marktime.labels, indent=4)
{
    "some another task": {
        "duration": 14.805735111236572,
        "start_time": 1370453758.064955,
        "end_time": 1370453772.87069
    },
    "some task # 3": {
        "start_time": 1370453892.025603,
        "end_time": None
    },
    "some task # 4": {
        "duration": 1.00120210647583,
        "start_time": 1370638027.000799,
        "end_time": 1370638028.002001
    },
    "some task": {
        "duration": 8.757422924041748,
        "start_time": 1370453753.185846,
        "end_time": 1370453761.943269
    }
}

API

  • marktime.start (label, at=None)

    • label — marker label. String. Required.

    • at — time to start the countdown. If None then uses time.time().

  • marktime.stop (label, remove_from_labels=False, stop_once=True)

    • label — marker label. String. Required.

    • at — time to stop the countdown. If None then uses time.time()

    • remove_from_labels — if True then label removed from global dict marktime.labels.

    • stop_once — if False and the countdown for the certain label is allready stopped thet it stopped it again. And thereafter the duration for the certain label will be increased.

  • marktime.duration (label, stop_it=True, stop_at=None)

    • label — marker label. String. Required.

    • stop_it — if True then the countdown for the certain label will be stopped. If False and the countdown for the certain label is not stopped then returns None.

    • stop_at — passed into stop function if stop_it == True

  • marktime.stopwatch (label) — context manager (with statement support)

  • marktime.labels — global dict that stores all the labels for time markers.

License

See LICENSE file.

Metadata

Release files for marktime 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marktime 0.2.0
File Size Uploaded Provenance Actions
marktime-0.2.0.tar.gz 3.2 kB Without provenance Details for marktime-0.2.0.tar.gz

Release files / marktime-0.2.0.tar.gz

Download URL marktime-0.2.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2006f6cb9a649c537137bf9be617d8ad524ecaaa352b509a903578aceb983ffd
BLAKE2b-256 checksum
How to use checksums
1400122c8fa4edebc084ae0273ed24079d10656d3d323e1e7a19d8e69b9d2002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for marktime 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file No provenance

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page