|
1 | 1 | # Performance Tests for ESDK Python
|
| 2 | + |
| 3 | +## License |
| 4 | + |
| 5 | +This project is licensed under the Apache-2.0 License. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +Here are the keyrings / master key-providers that we plan to test: |
| 10 | + |
| 11 | +1. KMS Keyring / KMS Master Key Provider |
| 12 | +2. Raw AES Keyring / AES Master Key Provider |
| 13 | +3. HKeyring / caching CMM example ("old" caching solution vs the (current) "new" caching solution) |
| 14 | +4. Raw RSA Keyring / RSA Master Key Provider |
| 15 | + |
| 16 | +For each test on the above keyrings / master key-providers, we measure the execution time and memory consumption in each test. |
| 17 | + |
| 18 | +For each keyring / master key-provider, we test the execution time and memory consumption time for three operations: |
| 19 | +1. Create keyring / master key-provider |
| 20 | +2. Encrypt |
| 21 | +3. Decrypt |
| 22 | + |
| 23 | +We demonstrate the usage of the performance tests through an [AWS KMS Keyring](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html). However, the procedure is the same for any keyring / master key-provider. |
| 24 | + |
| 25 | +The results for the performance test will be available in the results folder in the performance_tests directory. |
| 26 | + |
| 27 | +## Usage: Execution Time |
| 28 | + |
| 29 | +### Create Keyring |
| 30 | +To run the performance test for execution time, please use the following commands in the performance_tests directory |
| 31 | +``` |
| 32 | +python test/keyrings/test_aws_kms_keyring.py create |
| 33 | +``` |
| 34 | + |
| 35 | +#### Optional Arguments |
| 36 | +* kms_key_id: The KMS key ID you want to use |
| 37 | +* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the create_keyring method 100 times and report the execution time of each of the calls. |
| 38 | +* output_file: The output file for execution times for each function call, default='kms_keyring_create' in the results folder |
| 39 | + |
| 40 | +#### Consolidate Results |
| 41 | + |
| 42 | +In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: |
| 43 | +``` |
| 44 | +python consolidate_results.py results/kms_keyring_create.csv |
| 45 | +``` |
| 46 | + |
| 47 | +### Encrypt |
| 48 | +To run the performance test for execution time, please use the following commands in the performance_tests directory |
| 49 | +``` |
| 50 | +python test/keyrings/test_aws_kms_keyring.py encrypt |
| 51 | +``` |
| 52 | + |
| 53 | +Here, you will receive a prompt on the terminal to specify the plaintext file you want to encrypt. Some example plaintext data files are present in the 'test/resources' directory. |
| 54 | + |
| 55 | +Alternatively, if you want to provide the arguments as flags without using the interactive CLI, you can run the command in the following manner: |
| 56 | + |
| 57 | +``` |
| 58 | +python test/keyrings/test_aws_kms_keyring.py encrypt --plaintext_data_filename test/resources/plaintext-data-medium.dat |
| 59 | +``` |
| 60 | + |
| 61 | +You can choose to use any other plaintext file as well. |
| 62 | + |
| 63 | +#### Arguments |
| 64 | +* plaintext_data_filename: Filename containing plaintext data you want to encrypt |
| 65 | + |
| 66 | +#### Optional Arguments |
| 67 | +* kms_key_id: The KMS key ID you want to use to encrypt the data |
| 68 | +* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the encrypt method 100 times and report the execution time of each of the calls. |
| 69 | +* output_file: The output file for execution times for each function call, default='kms_keyring_encrypt' |
| 70 | + |
| 71 | +#### Consolidate Results |
| 72 | + |
| 73 | +In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: |
| 74 | +``` |
| 75 | +python consolidate_results.py results/kms_keyring_encrypt.csv |
| 76 | +``` |
| 77 | + |
| 78 | +### Decrypt |
| 79 | +To run the performance test for execution time, please use the following commands in the performance_tests directory |
| 80 | +``` |
| 81 | +python test/keyrings/test_aws_kms_keyring.py decrypt |
| 82 | +``` |
| 83 | + |
| 84 | +Here, you will receive a prompt on the terminal to specify the ciphertext file you want to decrypt. Some example ciphertext data files are present in the 'test/resources' directory. |
| 85 | + |
| 86 | +Alternatively, if you want to provide the arguments as flags without using the interactive CLI, you can run the command in the following manner: |
| 87 | + |
| 88 | +``` |
| 89 | +python test/keyrings/test_aws_kms_keyring.py decrypt --ciphertext_data_filename test/resources/ciphertext-data-medium.ct |
| 90 | +``` |
| 91 | + |
| 92 | +You can choose to use any other ciphertext file as well. |
| 93 | + |
| 94 | +#### Arguments |
| 95 | +* ciphertext_data_filename: Filename containing ciphertext data you want to decrypt |
| 96 | + |
| 97 | +#### Optional Arguments |
| 98 | +* kms_key_id: The KMS key ID you want to use to decrypt the data |
| 99 | +* n_iters: Number of iterations you want to run the test for. For instance, if n_iters = 100, this performance test script will run the decrypt method 100 times and report the execution time of each of the calls. |
| 100 | +* output_file: The output file for execution times for each function call, default='kms_keyring_decrypt' |
| 101 | + |
| 102 | +#### Consolidate Results |
| 103 | + |
| 104 | +In order to find the minimum, maximum and average times from the n_iters runs, please use the following script from the performance_tests directory: |
| 105 | +``` |
| 106 | +python consolidate_results.py results/kms_keyring_decrypt.csv |
| 107 | +``` |
| 108 | + |
| 109 | +## Usage: Memory Consumption |
| 110 | +To get the memory consumption, simply use 'mprof run' instead of 'python' in the previously mentioned commands. |
| 111 | + |
| 112 | +For example, if you want to calculate the memory consumption of the encrypt function of a AWS KMS Keyring, simply write: |
| 113 | +``` |
| 114 | +mprof run test/keyrings/test_aws_kms_keyring.py encrypt --plaintext_data_filename test/resources/plaintext-data-medium.dat |
| 115 | +``` |
| 116 | + |
| 117 | +This should generate an mprofile log file in your current directory. To plot the memory consumption with time, please use the following command from the same directory |
| 118 | +``` |
| 119 | +mprof plot |
| 120 | +``` |
| 121 | + |
| 122 | +This 'mprof plot' command will plot the most recent mprofile log file. |
| 123 | + |
| 124 | +## Usage: Performance Graph |
| 125 | +To generate a performance graph, please use the following command to generate the pstats log file by specifying the output pstats file path. Here, we use 'results/kms_keyring_create.pstats' as the output file. |
| 126 | + |
| 127 | +``` |
| 128 | +python -m cProfile -o results/kms_keyring_create.pstats test/keyrings/test_aws_kms_keyring.py create |
| 129 | +``` |
| 130 | + |
| 131 | +After generating the pstats file, please run the following command to generate the performance graph. The output performance graph will be a .png file that you specify. Here, we use 'results/kms_keyring_create.png' as the output file. |
| 132 | +``` |
| 133 | +gprof2dot -f pstats results/kms_keyring_create.pstats | dot -Tpng -o results/kms_keyring_create.png && eog results/kms_keyring_create.png |
| 134 | +``` |
0 commit comments