Skip to content

Commit

Permalink
Refactored result parsing scripts to improve efficiency and addressed…
Browse files Browse the repository at this point in the history
… bug in machine-id assignment for tls-testing
  • Loading branch information
crt26 committed Apr 22, 2024
1 parent 98a0587 commit 6b4e692
Show file tree
Hide file tree
Showing 7 changed files with 485 additions and 585 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
/test-data/keys
/test-data/up-results
/test-data/results
/temp-storage/
/temp-storage/
/scripts/parsing-scripts/__pycache__
259 changes: 0 additions & 259 deletions scripts/parsing-scripts/liboqs_avg_gen.py

This file was deleted.

38 changes: 15 additions & 23 deletions scripts/parsing-scripts/liboqs_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
import re
import os
import shutil
import sys
import subprocess
from liboqs_avg_gen import gen_averages
from results_averager import LiboqsResultAverager

# Declaring global variables
kem_operations = ["keygen", "encaps", "decaps"]
sig_operations = ["keypair", "sign", "verify"]
alg_operations = {'kem_operations': ["keygen", "encaps", "decaps"], 'sig_operations': ["keypair", "sign", "verify"]}
kem_algs = []
sig_algs = []
dir_paths = {}
Expand Down Expand Up @@ -56,10 +53,6 @@ def setup_parse_env() :
for line in alg_file:
sig_algs.append(line.strip())

algs_dict = {'kem_algs': kem_algs, 'sig_algs': sig_algs}

return algs_dict


#------------------------------------------------------------------------------
def handle_results_dir_creation(machine_num):
Expand Down Expand Up @@ -276,10 +269,8 @@ def memory_processing():
new_row = []
peak_metrics = []

# File placeholders
# Defining column names for dataframe
fieldnames = ["Algorithm", "Operation", "intits", "maxBytes", "maxHeap", "extHeap", "maxStack"]
kem_operations = ["keygen", "encaps", "decaps"]
sig_operations = ["keypair", "sign", "verify"]

# Looping through the number runs specified
for run_count in range(1, num_runs+1):
Expand All @@ -299,7 +290,7 @@ def memory_processing():

try:
peak_metrics = get_peak(kem_up_filepath, peak_metrics)
new_row.extend([kem_alg, kem_operations[operation]])
new_row.extend([kem_alg, alg_operations['kem_operations'][operation]])
new_row.extend(peak_metrics)

temp_df.loc[len(temp_df)] = new_row
Expand All @@ -320,8 +311,6 @@ def memory_processing():
# Looping through sig algorithms
for sig_alg in sig_algs:

#sig_up_filename_pre = os.path.join(sig_dir, sig_file_prefix)

# Looping the operations and adding to temp dataframe
for operation in range(0,3,1):

Expand All @@ -331,7 +320,7 @@ def memory_processing():

try:
peak_metrics = get_peak(sig_up_filepath, peak_metrics)
new_row.extend((sig_alg, sig_operations[operation]))
new_row.extend((sig_alg, alg_operations['sig_operations'][operation]))
new_row.extend(peak_metrics)
temp_df.loc[len(temp_df)] = new_row

Expand All @@ -350,13 +339,16 @@ def memory_processing():


#------------------------------------------------------------------------------
def process_tests(num_machines, algs_dicts):
def process_tests(num_machines):
""" Function for parsing the results for multiple machines
and stores them as csv files. Once up-results are processed
averages are calculated for the results """

global dir_paths

# Creating an instance of the liboq average generator class before processing results
liboqs_avg = LiboqsResultAverager(dir_paths, kem_algs, sig_algs, num_runs, alg_operations)

# Processing the results for the machine/s
for machine_num in range(1, num_machines+1):

Expand All @@ -367,17 +359,17 @@ def process_tests(num_machines, algs_dicts):
dir_paths['type_mem_dir'] = os.path.join(dir_paths['results_dir'], f"machine-{str(machine_num)}", "mem-results")
dir_paths['raw_speed_dir'] = os.path.join(dir_paths['up_results'], f"machine-{str(machine_num)}", "raw-speed-results")

# Creating required dirs and handling any clashes with previous parsed results
handle_results_dir_creation(machine_num)

print(f"machine dir_paths dict - \n{dir_paths}")

# Parsing results
pre_speed_processing()
speed_processing()
memory_processing()

# Calculating the averages for the parsed data
gen_averages(dir_paths, num_runs, algs_dicts)
# Calling average generation methods
liboqs_avg.avg_mem()
liboqs_avg.avg_speed()


#------------------------------------------------------------------------------
Expand All @@ -392,8 +384,8 @@ def parse_liboqs(test_opts):

# Setting up the script
print(f"\nPreparing to Parse Liboqs Results:\n")
algs_dict = setup_parse_env()
setup_parse_env()

# Processing the results
print("Parsing results... ")
process_tests(num_machines, algs_dict)
process_tests(num_machines)
Loading

0 comments on commit 6b4e692

Please sign in to comment.