Skip to content

Commit

Permalink
added analysis that draws AES comparison plot
Browse files Browse the repository at this point in the history
  • Loading branch information
PyryL committed Dec 8, 2023
1 parent eb2ba25 commit 340b758
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
__pycache__/
.pytest_cache/

# Derived files
analysis/*.csv
analysis/*.png

# Coverage
.coverage
htmlcov/
Expand Down
34 changes: 34 additions & 0 deletions analysis/aes_comparison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from matplotlib import pyplot as plt
from random import randbytes
from os import path
from perf_tests.test_aes_integration import run as run_with_aes
from perf_tests.test_encryption import run as run_without_aes

test_sample_sizes = [32, 96, 192, 512, 1024, 1504, 2048, 4096, 8192, 10_048]

times_with_aes = []
times_without_aes = []

for payload_length in test_sample_sizes:
payload = randbytes(payload_length)

durations = run_with_aes(payload)
times_with_aes.append(sum(durations))

durations = run_without_aes(payload)
times_without_aes.append(sum(durations))

print(f"Test {payload_length} completed")

# save CSV
with open(path.join(path.dirname(__file__), "aes_comparison.csv"), "w") as file:
file.write("payload size (bytes),time with AES,time without AES\n")
for size, time_with_aes, time_without_aes in zip(test_sample_sizes, times_with_aes, times_without_aes):
file.write(f"{size},{time_with_aes:.6f},{time_without_aes:.6f}\n")

# draw plot
plt.plot(test_sample_sizes, times_with_aes, marker="x", label="with AES")
plt.plot(test_sample_sizes, times_without_aes, marker="x", label="without AES")
plt.xlabel("Payload size, bytes")
plt.ylabel("Encryption + decryption time, seconds")
plt.show()
Loading

0 comments on commit 340b758

Please sign in to comment.