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:
checkSpeed(function, r)
where function
is any function from your Python file and r
is the number of times to run it. The average execution time is printed.
Example:
from speed import checkSpeed
def myFunc():
x = 2
for i in range(100):
x *= i
print(x)
n = 10
checkSpeed(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 is a string, not a float. This is to prevent Python from returning a result in scientific notation.
- While
checkSpeed()
runs a function, it blocks printing within that function so the terminal isn't filled with potentially hundreds of prints - Currently, passing arguments into the
function
argument e.g.checkSpeed(myFunc(a,b), 100)
doesn't work. I'll add this soon, with the syntax:checkSpeed(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.6.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for execspeed-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ac2b660f57ebc7b58d1f8d01ef422cf5f236700c4ef21534c78584127ac572a |
|
MD5 | 1c92951c03c11f0afdedf9cd892d3380 |
|
BLAKE2b-256 | a561f8603df0e0d49ab06eb93a756b194e39db031367edceb2c583aef10d8e14 |