FFpy - ⚡ Fast Python Script Execution Timer
FFpy is a command-line tool that measures the execution time of Python scripts. It provides flexibility by allowing you to specify the time unit (milliseconds or seconds) and the number of runs for more accurate measurements.
Background 🚀
As an undergraduate software engineer with Python as my weapon of choice for coding, I often found myself curious about the execution time of my scripts. While solutions like timeit module exist, I wanted a seamless way to measure execution time without adding another line of code to my programs. This led to the creation of FFpy.
In my coding journey, especially while tackling Data Structures and Algorithms problems and optimizing code, understanding the execution time can provide valuable insights.
FFpy aims to be a simple yet powerful tool for easily benchmarking performance without the need to modify your existing codebase. I believe in keeping things straightforward. FFpy is designed to be a minimalistic, no-nonsense module that integrates seamlessly into your workflow, allowing you to focus on coding while effortlessly obtaining execution time metrics.
Installation 🛠️
Install FFpy using pip:
pip install ffpy
Alternatively, you can clone this repository:
git clone https://github.com/anxkhn/FFpy.git
cd FFpy
pip install .
Usage 🚨
After installation, you can use FFpy to measure the execution time of your Python scripts. Here’s the basic syntax:
ffpy <filename.py> <filename2.py> [-u <unit>] [-n <num_runs>] [-s] [-v] [-h]
<filename.py>: Replace with the actual filename of your Python script in the current directory.
<filename2.py>: Optional second script for comparison.
-u, --unit: Optional flag to specify the time unit (ms or s, default is ms).
-n, --number: Optional flag to specify the number of runs (default is 1).
-s, --silent: Optional flag to run the script silently (suppress output).
-v, --version: Display script version.
-h, --help: Display help message.
Examples 🌈
Measure the execution time of a script in milliseconds:
ffpy script.py
Measure the execution time in seconds:
ffpy script.py -u s
Run the script 10 times and measure the average execution time:
ffpy script.py -n 10
Run the script silently:
ffpy script.py -s
Compare the execution times of two scripts:
ffpy bubble_sort.py merge_sort.py
How to Use 🤔
Start by including a simple hello.py Python script as an example:
print("Hello, FFpy!")
You can measure its execution time using FFpy:
ffpy hello.py
This should yield the following output:
Hello, FFpy! Execution time: XX.XX ms
Now, let’s examine the runtime of two different sorting algorithms. We have a list of 1000 integers, and we’ll use merge_sort.py and bubble_sort.py to sort them as examples:
ffpy merge_sort.py bubble_sort.py --silent
This will produce the following output:
merge_sort.py Execution time: 33.2839 ms bubble_sort.py Execution time: 65.3996 ms merge_sort.py is 96.49% faster than bubble_sort.py.
This difference in execution time is due to the fact that Merge sort is faster than bubble sort, thanks to its efficient divide-and-conquer approach, resulting in a time complexity of O(n log n). On the other hand, bubble sort, with its quadratic time complexity of O(n^2), proves to be less efficient for large datasets. We can clearly see the execution time differences between two programs.
Contributing 🤝
If you’d like to contribute to FFpy, feel free to fork the repository and submit a pull request.
License 📜
This project is licensed under the GPLv3 License - check out this website for more information.
Metadata
Release files for FFpy 1.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| FFpy-1.4.1.tar.gz | 4.5 kB | Without provenance | Details for FFpy-1.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| FFpy-1.4.1-py3-none-any.whl | Python 3 | none | any | Details for FFpy-1.4.1-py3-none-any.whl |
Total release size: 9.0 kB
Release files / FFpy-1.4.1.tar.gz
| Download URL | FFpy-1.4.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cdc234ed1a3073fcb9a1df514049e8274b6a06463a6843048b7ad01c47c92182
|
|
BLAKE2b-256 checksum How to use checksums |
9d2d51828dd176826879cd6abd05f84887297fcbb3552906f97f5645b21c642e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / FFpy-1.4.1-py3-none-any.whl
| Download URL | FFpy-1.4.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1177fb1c8d0c168b1615eaa76f2dd06a1f5cec4493608b567e17db63dd94814
|
|
BLAKE2b-256 checksum How to use checksums |
a691ead0ea4c9e3fd7767263d2b17c19d29353580addb128f500d3ad3da594d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for FFpy 1.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.