This tool was developed to speed up the execution time of programs written in Python, using a memoization-based approach applied to pure functions.
Go to the folder where the programs you want to accelerate are located.
$ cd </program_folders_path>
</program_folders_path>$ git clone https://github.com/dew-uff/speedupy.git
To exemplify, we use the speedup experiments repository, which can be obtained to test the tool by clicking on the link. After that, just unzip it and enjoy :-)
$ cd Downloads/speedupy_experiments-main/01pilots/01pilots_exp01_fibonacci
~/Downloads/speedupy_experiments-main/01pilots/01pilots_exp01_fibonacci $ git clone https://github.com/dew-uff/speedupy.git
For the tool to be able to interpret the experiment code, denote it with the following decorators:
- @deterministic - for each pure function that will be accelerated
- @initialize_intpy(__file__) - to the main function
In addition, it is necessary to have the following structure to call the main function:
-
if name =="__main__":
n = int(sys.argv[1])
start = time.perf_counter()
main(n)
print(time.perf_counter()-start) -
Adaptation may be necessary due to arguments passed as parameters in the main.
Example:
Figure 1: Code adapted from the nth Fibonacci term calculation.
Figure 2: Code adapted from the calculation of power, from a number n, to m.
Once the program is already adapted, just run it.
$ python <filename>.py program_params [-h, --help] [-g, --glossary] [-m memory|help, --memory memory|help] [-0, --no-cache] [- H type|help, --hash type|help] [-M method|help, --marshalling method|help] [-s form|help, --storage form|help]
To get an overview, just use the "-h" or "--help" argument and you will have all the valid arguments and their entries.
python fibonacci.py -h
Figure 3: Use of the general help with -h.
Once the arguments and their respective parameters have been discovered, we can use them as shown in the image below:
Figure 4: Example of defining some arguments.
Finally, if you want to know more about a specific argument, use the "help" after this argument:
Figure 5: Use of the arguments's help.