Simple tool for finding average function execution time
Project description
PyExecSpeed
A simple package for calculating the execution time of a function in a Python file
Usage:
Installation
pip install execspeed
Using
-
speed.showSpeed(function, r)
wherefunction
is any function from your Python file andr
is the number of times to run it. Prints average execution time. -
speed.getSpeed(function, r)
again,function
is any function from your Python file andr
is the number of times to run it. Returns average execution time as a float.
Example:
import speed
def myFunc():
x = 2
for i in range(100):
x *= i
print(x)
n = 10
speed.showSpeed(myFunc, n)
# Repeats myFunc n (= 10) times and prints the average execution time.
# A higher value of n will likely result in a more accurate value, but will take longer.
>>> 0.00003339
Notes:
- The output from
getSpeed()
is a float. - While
showSpeed()
orgetSpeed()
run a function, they block printing within that function so the terminal isn't filled with potentially hundreds of prints. - Currently, passing arguments into the
function
argument e.g.showSpeed(myFunc(a,b), 100)
doesn't work. I'll add this soon, with the syntax:showSpeed(function, r, <other>, <arguments>, <here>...)
, which will check the execution time offunction(other, arguments, here...)
Create an issue if you have any feedback / bugs you want to report
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
execspeed-0.0.9.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for execspeed-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a153acf5e6bfdc82ebd610b22450ec8ec6aef456ccc3206d675166a1b57f1de8 |
|
MD5 | 301e3fed506a4d43ca85845aee09d44f |
|
BLAKE2b-256 | ad34c0e500666d12efb8c8c8e5c6624bd4539f2c3a6909b31a94188eeb25b2bb |