|
@@ -23,6 +23,7 @@ import logging
|
|
import socket
|
|
import socket
|
|
import threading
|
|
import threading
|
|
import textwrap
|
|
import textwrap
|
|
|
|
+import shutil
|
|
from pprint import pprint
|
|
from pprint import pprint
|
|
|
|
|
|
from contextlib import contextmanager
|
|
from contextlib import contextmanager
|
|
@@ -43,6 +44,20 @@ class Benchmarker:
|
|
# Public methods
|
|
# Public methods
|
|
##########################################################################################
|
|
##########################################################################################
|
|
|
|
|
|
|
|
+ def clean_all(self):
|
|
|
|
+ if os.path.exists(self.results_directory):
|
|
|
|
+ for file in os.listdir(self.results_directory):
|
|
|
|
+ if not os.path.exists(os.path.dirname(file)):
|
|
|
|
+ shutil.rmtree(os.path.join(self.results_directory, file))
|
|
|
|
+ else:
|
|
|
|
+ os.remove(os.path.join(self.results_directory, file))
|
|
|
|
+
|
|
|
|
+ subprocess.check_call(["docker", "image", "prune", "-f"])
|
|
|
|
+
|
|
|
|
+ docker_ids = subprocess.check_output(["docker", "images", "-q"]).splitlines()
|
|
|
|
+ for docker_id in docker_ids:
|
|
|
|
+ subprocess.check_call(["docker", "image", "rmi", "-f", docker_id])
|
|
|
|
+
|
|
############################################################
|
|
############################################################
|
|
# Prints all the available tests
|
|
# Prints all the available tests
|
|
############################################################
|
|
############################################################
|
|
@@ -205,7 +220,7 @@ class Benchmarker:
|
|
# test_type timestamp/test_type/test_name/raw.txt
|
|
# test_type timestamp/test_type/test_name/raw.txt
|
|
############################################################
|
|
############################################################
|
|
def get_output_file(self, test_name, test_type):
|
|
def get_output_file(self, test_name, test_type):
|
|
- return os.path.join(self.result_directory, self.timestamp, test_name, test_type, "raw.txt")
|
|
|
|
|
|
+ return os.path.join(self.results_directory, self.timestamp, test_name, test_type, "raw.txt")
|
|
############################################################
|
|
############################################################
|
|
# End get_output_file
|
|
# End get_output_file
|
|
############################################################
|
|
############################################################
|
|
@@ -233,7 +248,7 @@ class Benchmarker:
|
|
# test_type timestamp/test_type/test_name/stats.txt
|
|
# test_type timestamp/test_type/test_name/stats.txt
|
|
############################################################
|
|
############################################################
|
|
def get_stats_file(self, test_name, test_type):
|
|
def get_stats_file(self, test_name, test_type):
|
|
- return os.path.join(self.result_directory, self.timestamp, test_name, test_type, "stats.txt")
|
|
|
|
|
|
+ return os.path.join(self.results_directory, self.timestamp, test_name, test_type, "stats.txt")
|
|
############################################################
|
|
############################################################
|
|
# End get_stats_file
|
|
# End get_stats_file
|
|
############################################################
|
|
############################################################
|
|
@@ -260,7 +275,7 @@ class Benchmarker:
|
|
# full_results_directory
|
|
# full_results_directory
|
|
############################################################
|
|
############################################################
|
|
def full_results_directory(self):
|
|
def full_results_directory(self):
|
|
- path = os.path.join(self.fwroot, self.result_directory, self.timestamp)
|
|
|
|
|
|
+ path = os.path.join(self.fwroot, self.results_directory, self.timestamp)
|
|
try:
|
|
try:
|
|
os.makedirs(path)
|
|
os.makedirs(path)
|
|
except OSError:
|
|
except OSError:
|
|
@@ -742,7 +757,9 @@ class Benchmarker:
|
|
docker_id = subprocess.check_output(["docker", "ps", "-q"]).strip()
|
|
docker_id = subprocess.check_output(["docker", "ps", "-q"]).strip()
|
|
# We still need to sleep a bit before removing the image
|
|
# We still need to sleep a bit before removing the image
|
|
time.sleep(5)
|
|
time.sleep(5)
|
|
- subprocess.check_output(["docker", "image", "rm", "tfb/test/%s" % test.name])
|
|
|
|
|
|
+ subprocess.check_call(["docker", "image", "rm", "tfb/test/%s" % test.name])
|
|
|
|
+ time.sleep(5)
|
|
|
|
+ subprocess.check_call(["docker", "image", "prune", "-f"])
|
|
############################################################
|
|
############################################################
|
|
# End __stop_test
|
|
# End __stop_test
|
|
############################################################
|
|
############################################################
|
|
@@ -930,10 +947,10 @@ class Benchmarker:
|
|
pass
|
|
pass
|
|
|
|
|
|
def __get_git_commit_id(self):
|
|
def __get_git_commit_id(self):
|
|
- return subprocess.check_output('git rev-parse HEAD', shell=True).strip()
|
|
|
|
|
|
+ return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
|
|
|
|
|
|
def __get_git_repository_url(self):
|
|
def __get_git_repository_url(self):
|
|
- return subprocess.check_output('git config --get remote.origin.url', shell=True).strip()
|
|
|
|
|
|
+ return subprocess.check_output(["git", "config", "--get", "remote.origin.url"]).strip()
|
|
|
|
|
|
############################################################
|
|
############################################################
|
|
# __finish
|
|
# __finish
|
|
@@ -963,7 +980,7 @@ class Benchmarker:
|
|
print(prefix + header('', top='', bottom='=') + Style.RESET_ALL)
|
|
print(prefix + header('', top='', bottom='=') + Style.RESET_ALL)
|
|
|
|
|
|
print("Time to complete: " + str(int(time.time() - self.start_time)) + " seconds")
|
|
print("Time to complete: " + str(int(time.time() - self.start_time)) + " seconds")
|
|
- print("Results are saved in " + os.path.join(self.result_directory, self.timestamp))
|
|
|
|
|
|
+ print("Results are saved in " + os.path.join(self.results_directory, self.timestamp))
|
|
|
|
|
|
############################################################
|
|
############################################################
|
|
# End __finish
|
|
# End __finish
|
|
@@ -1001,7 +1018,6 @@ class Benchmarker:
|
|
args['pipeline_concurrency_levels'] = [256,1024,4096,16384]
|
|
args['pipeline_concurrency_levels'] = [256,1024,4096,16384]
|
|
|
|
|
|
self.__dict__.update(args)
|
|
self.__dict__.update(args)
|
|
- # pprint(self.__dict__)
|
|
|
|
|
|
|
|
self.quiet_out = QuietOutputStream(self.quiet)
|
|
self.quiet_out = QuietOutputStream(self.quiet)
|
|
|
|
|
|
@@ -1028,16 +1044,7 @@ class Benchmarker:
|
|
self.timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime())
|
|
self.timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime())
|
|
|
|
|
|
# setup results and latest_results directories
|
|
# setup results and latest_results directories
|
|
- self.result_directory = os.path.join(self.fwroot, "results")
|
|
|
|
- if (args['clean'] or args['clean_all']) and os.path.exists(os.path.join(self.fwroot, "results")):
|
|
|
|
- os.system("sudo rm -rf " + self.result_directory + "/*")
|
|
|
|
-
|
|
|
|
- # TODO: remove this as installs goes away with docker implementation
|
|
|
|
- # remove installs directories if --clean-all provided
|
|
|
|
- self.install_root = "%s/%s" % (self.fwroot, "installs")
|
|
|
|
- if args['clean_all']:
|
|
|
|
- os.system("sudo rm -rf " + self.install_root)
|
|
|
|
- os.mkdir(self.install_root)
|
|
|
|
|
|
+ self.results_directory = os.path.join(self.fwroot, "results")
|
|
|
|
|
|
self.results = None
|
|
self.results = None
|
|
try:
|
|
try:
|