Skip to content

peterpy - Print Elapsed TimE Running a piece of Python code

License

Notifications You must be signed in to change notification settings

javiribera/peterpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

peterpy

Add peter's context manager around your code and it will measure how long it takes to run:

from peterpy import peter

with peter('Running some code'):
    fib = lambda n: n if n < 2 else fib(n-1) + fib(n-2)
    fib(30)

Running some code... DONE (took 0.590127 seconds)

pip install peterpy

Pull and install in the current directory:

pip install git+https://github.com/javiribera/peterpy.git@master
class peter():
"""
Context manager that will print
the time elapsed while executing the code inside it.
"""

    def __init__(self,
                 msg="Running",
                 erase_stdout=False,
                 erase_stderr=False):
  • msg : str, optional
    Message to show on standard output before running. Default: "Running..."
  • erase_stdout : bool, optional
    Ignore everything sent to the standard output inside the context. Default: False
  • erase_stderr : bool, optional
    Ignore everything sent to the standard error inside the context. Default: False

About

peterpy - Print Elapsed TimE Running a piece of Python code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages