Giter Club home page Giter Club logo

marktime.py's Introduction

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').sec
8.757422924041748

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

marktime.duration('some another task').msec
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.

marktime.py's People

Contributors

ekalinin avatar hannibal1296 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

marktime.py's Issues

error mesage

import marktime
marktime.start('some task')
marktime.duration('some task')
<marktime.Duration object at 0xb6c948b0>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.