Skip to content

Commit 8bfb71e

Browse files
committed
fix
1 parent 6573a46 commit 8bfb71e

File tree

6 files changed

+88
-19
lines changed

6 files changed

+88
-19
lines changed

performance_tests/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
# Performance Tests for ESDK Python
1+
# aws-encryption-sdk performance tests
22

33
## License
44

55
This project is licensed under the Apache-2.0 License.
66

77
## Overview
88

9-
Here are the keyrings / master key-providers that we are testing:
9+
This library tests the following keyrings / master key-providers:
1010

1111
1. KMS Keyring / KMS Master Key Provider
1212
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
13+
3. Raw RSA Keyring / RSA Master Key Provider
14+
4. Hierarchy Keyring
15+
5. Caching CMM
1516

16-
For each test on the above keyrings / master key-providers, we measure the execution time and memory consumption in each test.
17+
For each test on the above keyrings / master key-providers, this package measures the execution time and memory consumption.
1718

18-
For each keyring / master key-provider, we test the execution time and memory consumption time for three operations:
19+
For each keyring / master key-provider, the execution time and memory consumption time is measured for three operations:
1920
1. Create keyring / master key-provider
2021
2. Encrypt
2122
3. Decrypt
2223

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, with slight change in the input arguments.
24+
The usage of the performance tests is demonstrated 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, with slight change in the input arguments.
2425

2526
The results for the performance test will be available in the results folder in the performance_tests directory.
2627

@@ -122,13 +123,13 @@ mprof plot
122123
This 'mprof plot' command will plot the most recent mprofile log file.
123124

124125
## 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+
To generate a performance graph, please use the following command to generate the pstats log file by specifying the output pstats file path. Here, 'results/kms_keyring_create.pstats' is set as the default output file.
126127

127128
```
128129
python -m cProfile -o results/kms_keyring_create.pstats test/keyrings/test_aws_kms_keyring.py create
129130
```
130131

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+
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, 'results/kms_keyring_create.png' is set as the default output file.
132133
```
133134
gprof2dot -f pstats results/kms_keyring_create.pstats | dot -Tpng -o results/kms_keyring_create.png && eog results/kms_keyring_create.png
134135
```

performance_tests/consolidate_results.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def calculate_statistics(_csv_file):
11-
"""Calculate min, max, average and p99 statistics for execution times in a CSV file."""
11+
"""Calculate average, trimmed average, minimum, maximum and p99 statistics for execution times in a CSV file."""
1212
with open(_csv_file, 'r', encoding='utf-8') as file:
1313
reader = csv.reader(file)
1414
data = [float(row[0]) for row in reader]
@@ -17,12 +17,12 @@ def calculate_statistics(_csv_file):
1717
if data:
1818
data = np.sort(data)
1919
_total_entries = len(data)
20-
_average = sum(data) / _total_entries
21-
_trimmed_average_99 = np.mean(data[0:int(0.99 * len(data))])
20+
_average = np.mean(data)
21+
_trimmed_average_99_bottom = np.mean(data[0:int(0.99 * len(data))])
2222
_minimum = min(data)
2323
_maximum = max(data)
2424
_perc_99 = np.percentile(data, 99)
25-
return _total_entries, _average, _trimmed_average_99, _minimum, _maximum, _perc_99
25+
return _total_entries, _average, _trimmed_average_99_bottom, _minimum, _maximum, _perc_99
2626

2727
return None
2828

@@ -35,11 +35,11 @@ def calculate_statistics(_csv_file):
3535

3636
statistics = calculate_statistics(args.csv_file)
3737
if statistics:
38-
total_entries, average, trimmend_average_99, minimum, maximum, perc_99 = statistics
38+
total_entries, average, trimmend_average_99_bottom, minimum, maximum, perc_99 = statistics
3939
print("CSV File:", args.csv_file)
4040
print("Total Entries:", total_entries)
4141
print("Average:", average)
42-
print("99th percentile trimmed average:", trimmend_average_99)
42+
print("Bottom 99th percentile trimmed average:", trimmend_average_99_bottom)
4343
print("Minimum:", minimum)
4444
print("Maximum:", maximum)
4545
print("99th percentile:", perc_99)

performance_tests/src/aws_encryption_sdk_performance_tests/utils/util.py

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,74 @@ class PerfTestUtils:
77
"""Utility functions for AWS Encryption SDK performance tests."""
88
DEFAULT_N_ITERS = 100
99
DEFAULT_FILE_SIZE = 'small'
10+
DEFAULT_AES_256_STATIC_KEY = \
11+
b'_\xcf"\x82\x03\x12\x9d\x00\x8a\xed\xaf\xe4\x80\x1d\x00t\xa6P\xac\xb6\xfe\xc5\xf6/{\xe7\xaaO\x01\x13W\x85'
12+
DEFAULT_RSA_PUBLIC_KEY = bytes("-----BEGIN PUBLIC KEY-----\n"
13+
+ "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwEkp2yRpTAgZa4MDNxq8"
14+
+ "eQ7rkaVw9QTdJr9NFAtjUpM/6UQARJ2aAq8SjzkGk94EqfH6XqMWum/XQDIb5IWy"
15+
+ "E2nm4MCHED62mEEbjbDwtLmiWK0giZV3qe1PJ1LRLmeqRvjVHWc0b7QxnkjPCCnf"
16+
+ "Mpode5IQY3AZM3unIVFA043oD3ZPRsEch/hl2my2sxBa4PNod2cxw1PLbQVQWvKh"
17+
+ "f7ivmhVAKxwacXTb2yIynGljEgZZfkV1hATS9TGgHG2wpeZ9o0M4/JaN+TLgjruv"
18+
+ "gaE6vArdndBQcUV/NAOBeDegsfAsic7OC9FD/3MFgLo2g72WYY3BuCNMDj8L3lWK"
19+
+ "+vyC/S66cIvp1P2GzsccHSfcK0MC09ojnCbKF6D7tv5pIKhtvZRC7xcNv1ctS/fb"
20+
+ "UbMy4tH+8iwvJlTRGZuuEYD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XKAVBP6sufXRmRSoVqLO/olY2ExjFuVHdSJZLsSKZ/a8eBbituN9WcCN+YCF7"
68+
+ "u+65izM3j9K1y9CmV0igVQgV7VNhQ2OsEX/aHcWQPg1tHl94TxEe/MNX0sDKq9Ia"
69+
+ "PfPYC8TT0s1qngq23TzF8ZwDxI4aSqC3uV8t80Yq0BhXYGAS7YsLnO22KGCVeF3A"
70+
+ "gOOXpeJhIg7PkSRDY0Qn7XnVHO0UJyBmrHNatquiHX/L9vHtFSiNcT7NnII9G2bf"
71+
+ "s9GP+78f865LEXBzWqJvA5Nad2/NLckCggEANWMjb5QcJqTSXn0f2UqJ7AicWoqQ"
72+
+ "dMjpY79N+2iz2tlNFD9/BC/l6QGhM4YMVLNDwM2Aak37P8ZnQ9frEjMCEoD2bIlO"
73+
+ "cWxVaXMP39rnLUPzg8D2TcjiQ2NBL4FDYXudZCUh4b1x70Gp2GiP7GxZwv2/SQhD"
74+
+ "j7cc4oNwaE1hkiMhAYbPgWUU06JQwWPcD8UmKUgdp2ET+eUEwfV0GVtNOSfGoenf"
75+
+ "ZqdaYcE8c3ft37JM5AsKo5h+G3qHOBRMEYHtQDybuvvFsg+hJ0BuxYt4mFubWZYL"
76+
+ "V/tu4K1kmEZXgTvNZWSsZaIY2xBus2Ol2rKTahA0d9ffGeUhRj+UQrWpxg=="
77+
+ "\n-----END RSA PRIVATE KEY-----", "utf-8")
1078

1179
@staticmethod
1280
def read_file(filename):
@@ -26,8 +94,8 @@ def get_rsa_key_from_file(filename):
2694
return key
2795

2896
@staticmethod
29-
def print_time_list_to_csv(time_list, filename):
30-
"""Prints the time list to a CSV file."""
97+
def write_time_list_to_csv(time_list, filename):
98+
"""Writes the time list to a CSV file."""
3199
with open('results/' + filename + '.csv', 'w', encoding='utf-8') as myfile:
32100
for time in time_list:
33101
myfile.write(str(time) + '\n')

performance_tests/test/keyrings/test_aws_kms_keyring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
from aws_encryption_sdk_performance_tests.keyrings.aws_kms_keyring import (
1111
create_keyring,
12-
create_kms_client,
1312
create_keyring_given_kms_client,
13+
create_kms_client,
1414
decrypt_using_keyring,
1515
encrypt_using_keyring,
1616
)

performance_tests/test/master_key_providers/test_aws_kms_master_key_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import click
88
from tqdm import tqdm
99

10-
from aws_encryption_sdk_performance_tests.master_key_providers.aws_kms_key_provider import (
10+
from aws_encryption_sdk_performance_tests.master_key_providers.aws_kms_master_key_provider import (
1111
create_key_provider,
1212
decrypt_using_key_provider,
1313
encrypt_using_key_provider,

0 commit comments

Comments
 (0)