Skip to main content

The fuss-free way to time functions

Project description

JustTimeit.py


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":
            break
        elif Wallet == "thicc":
            # stop lying to yourself
            break
    return "big sad"
YourWallet = "empty"
result = shakyRelationship(YourWallet)
print(time.time()-starttime)
>>> 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.

Requirements

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

Installation

pip install just-time-it

Quickstart/Documentation

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).

printr=1

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).

printr=2

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)")
print(result)
>>> Time Taken for multiply(3,5): 1.0940176924541224e-06 . Repeated 1 time(s).
>>> 15

returnr=1

Return the time taken for the function to complete

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

returnr=2

Return both result and time taken

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

returnr=2,printr=2

Return result and time taken without printing anything

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

Globals

Have variables? use globals=globals()

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

Technology

JustTimeit.py 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.

Testing

good joke

Support

For Technical Issues: www.stackoverflow.com

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

FAQ

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()
multiply(3,7)
print("time.time()",(time.time()-starttime))
>>> 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)

timefunc("multiply(3,7)")
>>> 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.

License


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.

Source Distribution

just-time-it-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

just_time_it-0.1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file just-time-it-0.1.2.tar.gz.

File metadata

  • Download URL: just-time-it-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7

File hashes

Hashes for just-time-it-0.1.2.tar.gz
Algorithm Hash digest
SHA256 424c3aa28dc3e74a6cdc133245a1f32d5c54d6272a2e162cb896762859c01b11
MD5 3ea0ceb0d1aa9ba9366554c29b2f5038
BLAKE2b-256 1bee0b52d25eaa0a93143287ade24c284b0b31c9b283a48e1ff235ecd0222714

See more details on using hashes here.

File details

Details for the file just_time_it-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: just_time_it-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7

File hashes

Hashes for just_time_it-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 61a5f1db7187b9d8edf15cda8a985776e19ab815c12e691c22fe5686cb5c95a6
MD5 3d36aab10ee7f6d44846ce8bbd334535
BLAKE2b-256 c0d72f023654bed2a0c316d24266add077ff6b7ab85d433b2058031336748cf2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page