Git Product home page Git Product logo

tim's Introduction

Tim: Timed iteration monitor

A common pattern I have when writing code to import or treat large chunk of data is to do some printing to track the progress and some timing to monitor the speed. So I often end up with some variation of this in my code:

from datetime import datetime
start = datetime.now()
n = 0
for i in my_iter:
    n+=1
    print "\r", i,
    # do stuff
print start - datetime.now()
print (start - datetime.now()) / n / 100

which is a lot to remember and type which in turn make it easy to introduce bugs in some edge case which you need then to debug.

So I wrote tim to help me do just that, so I have this pattern ready for use and working and can spend my time coding my data treatment instead of debbugging my helper code.

WARNING : This is alpha level stuff, I'm still working out the proper way to do stuff so the API may still change a bit.

How to use tim

Common usage pattern would probably be:

import tim

tim.start()
for i in my_iter:
    tim.pulse_print() # print current progress
    # do stuff
tim.stop() # print overall stats and reset counter

If you just need to monitor start and stop you can use:

tim.start()
# calculation
tim.stop() # print elapsed time and reset

tim's People

Contributors

olethanh avatar psycojoker avatar

Watchers

 avatar James Cloos avatar  avatar

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.