To install the required libraries, run the following command in your terminal:
pip install -r requirements.txt
This script compares various Python methods in terms of execution time, memory usage, and CPU usage.
Defines various Python methods to be compared, such as using loops, list comprehensions, map function, and numpy, including a recursive function.
Holds references to the method functions and a flag indicating whether the method is recursive.
methods = {
'For Loop': {'func': for_loop, 'recursive': False},
# ... other methods ...
}
Iterates over different sample sizes and repeat counts.
Runs each method and measures execution time, memory usage, and average CPU usage.
Skips recursive methods if the sample size exceeds the adjusted system recursion limit.
For each sample size, it creates a summary table, sorts it by execution time, and stores its string representation.
After all computations, prints out each summary table, one for each sample size.
Usage:
python performance_comparison.py