Skip to main content

The fuss-free way to time functions

Project description

License Coverage Status Build Status GitHub file size in bytes Python Version Dependencies My Looks OwO

Don't have enough dependencies with poor documentation in your projects? Have an undying desire for more broken code for important functions? Eat cereal with water? Or just an all-round masochist? (Just kidding, we're all programmers, we're all masochists)

Boy, do I have the solution for you.

Hurt me harder daddy

Too lazy to wrap your functions with this?

import time
starttime = time.time()
def shakyRelationship(Wallet):
    while True:
        if Wallet == "empty":
        elif Wallet == "thicc":
            # stop lying to yourself
    return "big sad"
YourWallet = "empty"
result = shakyRelationship(YourWallet)
>>> 1.0940176924541224e-06

Now you can wrap it like this

from timefunctions import timefunc
MyWallet = "thicc"
result = timefunc("shakyRelationship(MyWallet)",globals=globals()) # Only include globals() if you have variables
>>> Time Taken for yourfunction: 1.0940176924541224e-06 . Repeated 1 time(s).

This package can't save your relationships but it can save you that 3 seconds.

Now you can go spend more time learning Tensorflow for that interesting python uncensoring project.


Python3.6+. Have anything older than Python3.6? You're either working corporate (see: FAQ) or a masochist (see: Support/Personal Issues)


pip install just-time-it


Lets define a example function

def multiply(x,y):
    return x*y

printr=0 (default)

Print function name without arguments

from timefunctions import timefunc
result = timefunc("multiply(3,5)")
>>> Time Taken for multiply: 1.0940176924541224e-06 . Repeated 1 time(s).


Print Function name with arguments

from timefunctions import timefunc
result = timefunc("multiply(3,5)",printr=1)
>>> Time Taken for multiply(3,5): 1.0940176924541224e-06 . Repeated 1 time(s).


Print nothing

from timefunctions import timefunc
result = timefunc("multiply(3,5)",printr=2)

returnr=0 (default)

Return the result of your function

from timefunctions import timefunc
result = timefunc("multiply(3,5)")
>>> Time Taken for multiply(3,5): 1.0940176924541224e-06 . Repeated 1 time(s).
>>> 15


Return the time taken for the function to complete

from timefunctions import timefunc
result = timefunc("multiply(3,5)",returnr=1)
>>> Time Taken for multiply(3,5): 1.0940176924541224e-06 . Repeated 1 time(s).
>>> 1.0940176924541224e-06


Return both result and time taken

from timefunctions import timefunc
result = timefunc("multiply(3,5)",returnr=2)
>>> Time Taken for multiply(3,5): 1.0940176924541224e-06 . Repeated 1 time(s).
>>> (1.0940176924541224e-06,15)


Return result and time taken without printing anything

from timefunctions import timefunc
result = timefunc("multiply(3,5)",printr=2,returnr=2)
>>> (1.0940176924541224e-06,15)


Have variables? use globals=globals()

from timefunctions import timefunc
result = timefunc("multiply(x,y)",globals=globals())
>>> Time Taken for multiply(x,y): 1.0940176924541224e-06 . Repeated 1 time(s).

Technology uses Object-Oriented, Dynamic Programming, Augmented Reality, Machine Learning, Artificial Neural Networks, GPT-2 and my Big Data to ensure you save that 3 seconds.


good joke


For Technical Issues:

For Personal Issues: Sounds like your own personal problem, let's keep it that way.


Should I use this?

No, this is like the worst possible combination of words to ever grace this Earth.

Can I change the README to be more professional?

I'll put this entire file through an OwO generator if you try

I'm a born masochist, I still use Python2.3. Will there be support for Python3.5 or other earlier depreciated versions?

If I wanted to torture myself with compatibility issues, I might as well go into the dating scene.

Caveats/Warnings (Serious)

This code is not accurate. Any function you are testing that is under 0.1 seconds should NOT rely on this package. A normal function that executes for around 0.9 seconds will look like this under different code

Example slow code

# Around 0.9 seconds to run
def multiply(x,y):
    for d in range(10000000):
        xy = d*x*y
    return None

Normal time.time()

starttime = time.time()
>>> time.time() 0.8946394920349121

timeit with setup

print("timesetup",timeit.timeit("multiply(3,7)",setup="from /__main__ import multiply",number=ss))
>>> timesetup 0.9034562206940011

timefunc (this package)

>>> Time Taken for multiply: 0.84726418995648 . Repeated 1 time(s).

They are roughly similar with a maximum of 0.1 differences. You can try altering range(10000000) to see the differences in the code.


GLWT(Good Luck With That) Public License

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 just-time-it, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size just_time_it-0.1.2-py3-none-any.whl (5.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size just-time-it-0.1.2.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page