Skip to content

dew-uff/speedupy

Repository files navigation

Speedupy

This tool was developed to speed up the execution time of programs written in Python, using a memoization-based approach applied to pure functions.

How to use?

Prepare the directories

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

Prepare the files

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:

screen1_speedupy

Figure 1: Code adapted from the nth Fibonacci term calculation.

screen2_speedupy

Figure 2: Code adapted from the calculation of power, from a number n, to m.

Running the programs

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

screen3_speedupy

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:

screen4_speedupy

Figure 4: Example of defining some arguments.

Finally, if you want to know more about a specific argument, use the "help" after this argument:

screen5_speedupy

Figure 5: Use of the arguments's help.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages