Skip to content
Snippets Groups Projects
Commit f6ce775c authored by Elizabeth's avatar Elizabeth
Browse files

Implemented simple script to manage and run binaries

parent 9bb91d78
No related branches found
No related tags found
No related merge requests found
# Automates online benchmark testing with different clock speeds
# Input: set of benchmark names to test
# Set of benchmarks format: (full_bin_name, half_bin_name)
import os
import sys
from collections import defaultdict
from subprocess import Popen, PIPE
def run_benchmark(bin_name, should_print_bin_output):
print("RUNNING %s" % bin_name)
proc = Popen("./%s" % bin_name, stdout = PIPE, universal_newlines = True)
proc_output = proc.communicate()[0]
assert proc.returncode == 0
if should_print_bin_output:
print(proc_output)
print("FINISHED RUNNING %s" % bin_name)
return proc_output
def parse_binary_output(proc_output):
avg_time_key_ind = proc_output.find("Average time:")
assert avg_time_key_ind >= 0
avg_time = proc_output[avg_time_key_ind : proc_output.find("\n", avg_time_key_ind)]
print(avg_time)
return avg_time
# Input: a list of tuples of benchmark names
# Can change to input a file containing benchmarks to run
def run_benchmarks(builds_dir, output_filename, should_print_bin_output = True):
output_file = open(output_filename, "w")
for bin_name in os.listdir(builds_dir):
if bin_name.find("profiling") == -1:
continue
output_file.write("%s: %s\n" % (bin_name, \
parse_binary_output(run_benchmark(os.path.join(builds_dir, bin_name), \
should_print_bin_output))))
print(bin_name)
output_file.close()
if __name__ == "__main__":
num_args = len(sys.argv)
if num_args != 3:
print("Usage: python online_benchmark_testing_automator.py <builds dir> <outputs_file_name>")
exit(1)
print("Output file name: %s" % sys.argv[2])
run_benchmarks(sys.argv[1], sys.argv[2])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment