test-zstd-speed.py: improved formatting
This commit is contained in:
parent
c9bb102401
commit
2d9272f1dd
@ -13,44 +13,41 @@ test_dir_name = 'speedTest'
|
|||||||
email_header = '[ZSTD_speedTest]'
|
email_header = '[ZSTD_speedTest]'
|
||||||
|
|
||||||
def log(text):
|
def log(text):
|
||||||
print time.strftime("%Y/%m/%d %H:%M:%S") + ' - ' + text
|
print(time.strftime("%Y/%m/%d %H:%M:%S") + ' - ' + text)
|
||||||
|
|
||||||
def execute(command, print_output=False, print_error=True):
|
|
||||||
|
def execute(command, print_output=False, print_error=True, param_shell=True):
|
||||||
log("> " + command)
|
log("> " + command)
|
||||||
popen = Popen(command, stdout=PIPE, stderr=PIPE, shell=True, cwd=execute.cwd)
|
popen = Popen(command, stdout=PIPE, stderr=PIPE, shell=param_shell, cwd=execute.cwd)
|
||||||
itout = iter(popen.stdout.readline, b"")
|
itout = iter(popen.stdout.readline, b"")
|
||||||
iterr = iter(popen.stderr.readline, b"")
|
iterr = iter(popen.stderr.readline, b"")
|
||||||
stdout_lines = list(itout)
|
stdout_lines = list(itout)
|
||||||
if print_output:
|
|
||||||
print ''.join(stdout_lines)
|
|
||||||
stderr_lines = list(iterr)
|
stderr_lines = list(iterr)
|
||||||
if print_output:
|
|
||||||
print ''.join(stderr_lines)
|
|
||||||
popen.communicate()
|
popen.communicate()
|
||||||
|
if print_output:
|
||||||
|
print(''.join(stdout_lines))
|
||||||
|
print(''.join(stderr_lines))
|
||||||
if popen.returncode is not None and popen.returncode != 0:
|
if popen.returncode is not None and popen.returncode != 0:
|
||||||
if not print_output and print_error:
|
if not print_output and print_error:
|
||||||
print ''.join(stderr_lines)
|
print(''.join(stderr_lines))
|
||||||
raise RuntimeError(''.join(stderr_lines))
|
return popen.returncode, stdout_lines, stderr_lines
|
||||||
return stdout_lines + stderr_lines
|
|
||||||
execute.cwd = None
|
execute.cwd = None
|
||||||
|
|
||||||
|
|
||||||
def does_command_exist(command):
|
def does_command_exist(command):
|
||||||
try:
|
result, stdoutdata, stderrdata = execute(command, False, False);
|
||||||
execute(command, False, False);
|
return result == 0
|
||||||
except Exception as e:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def fetch():
|
def fetch():
|
||||||
execute('git fetch -p')
|
execute('git fetch -p')
|
||||||
output = execute('git branch -rl')
|
returncode, output, stderrdata = execute('git branch -rl')
|
||||||
for line in output:
|
for line in output:
|
||||||
if "HEAD" in line:
|
if "HEAD" in line:
|
||||||
output.remove(line) # remove "origin/HEAD -> origin/dev"
|
output.remove(line) # remove "origin/HEAD -> origin/dev"
|
||||||
branches = map(lambda l: l.strip(), output)
|
branches = map(lambda l: l.strip(), output)
|
||||||
return map(lambda b: (b, execute('git show -s --format=%h ' + b)[0].strip()), branches)
|
print("branches=%s" % branches)
|
||||||
|
return map(lambda b: (b, execute('git show -s --format=%h ' + b)[1][0].strip()), branches)
|
||||||
|
|
||||||
|
|
||||||
def notify(branch, commit, last_commit):
|
def notify(branch, commit, last_commit):
|
||||||
@ -58,14 +55,13 @@ def notify(branch, commit, last_commit):
|
|||||||
branch = branch.split('/')[1]
|
branch = branch.split('/')[1]
|
||||||
fmt = '--format="%h: (%an) %s, %ar"'
|
fmt = '--format="%h: (%an) %s, %ar"'
|
||||||
if last_commit is None:
|
if last_commit is None:
|
||||||
commits = execute('git log -n 10 %s %s' % (fmt, commit))
|
returncode, commits, stderrdata = execute('git log -n 10 %s %s' % (fmt, commit))
|
||||||
else:
|
else:
|
||||||
commits = execute('git --no-pager log %s %s..%s' % (fmt, last_commit, commit))
|
returncode, commits, stderrdata = execute('git --no-pager log %s %s..%s' % (fmt, last_commit, commit))
|
||||||
|
|
||||||
text = text_tmpl.substitute({'last_commit': last_commit, 'commits': ''.join(commits)})
|
text = text_tmpl.substitute({'last_commit': last_commit, 'commits': ''.join(commits)})
|
||||||
print str("commits for %s: %s" % (commit, text))
|
print(str("commits for %s: %s" % (commit, text)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def compile(branch, commit, dry_run):
|
def compile(branch, commit, dry_run):
|
||||||
local_branch = string.split(branch, '/')[1]
|
local_branch = string.split(branch, '/')[1]
|
||||||
version = local_branch.rpartition('-')[2]
|
version = local_branch.rpartition('-')[2]
|
||||||
@ -102,7 +98,7 @@ def benchmark_and_compare(branch, commit, resultsFileName, lastCLevel, testFileP
|
|||||||
log("WARNING: bench loadavg=%.2f is higher than %s, sleeping for %s seconds" % (os.getloadavg()[0], maxLoadAvg, sleepTime))
|
log("WARNING: bench loadavg=%.2f is higher than %s, sleeping for %s seconds" % (os.getloadavg()[0], maxLoadAvg, sleepTime))
|
||||||
time.sleep(sleepTime)
|
time.sleep(sleepTime)
|
||||||
start_load = str(os.getloadavg())
|
start_load = str(os.getloadavg())
|
||||||
result = execute('programs/zstd -qi5b1e' + str(lastCLevel) + ' ' + testFilePath)
|
returncode, result, stderrdata = execute('programs/zstd -qi5b1e' + str(lastCLevel) + ' ' + testFilePath)
|
||||||
end_load = str(os.getloadavg())
|
end_load = str(os.getloadavg())
|
||||||
linesExpected = lastCLevel + 2;
|
linesExpected = lastCLevel + 2;
|
||||||
if len(result) != linesExpected:
|
if len(result) != linesExpected:
|
||||||
@ -184,7 +180,7 @@ def check_branches(args, test_path, testFilePaths, have_mutt, have_mail):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
stack = traceback.format_exc()
|
stack = traceback.format_exc()
|
||||||
log("ERROR: build %s, error %s" % (branch, str(e)) )
|
log("ERROR: build %s, error %s" % (branch, str(e)) )
|
||||||
print stack
|
print(stack)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -214,24 +210,24 @@ if __name__ == '__main__':
|
|||||||
clone_path = test_path + '/' + 'zstd' # /path/to/zstd/tests/speedTest/zstd
|
clone_path = test_path + '/' + 'zstd' # /path/to/zstd/tests/speedTest/zstd
|
||||||
|
|
||||||
# check availability of e-mail senders
|
# check availability of e-mail senders
|
||||||
have_mutt = does_command_exist("mutt --help");
|
have_mutt = does_command_exist("mutt -h");
|
||||||
have_mail = does_command_exist("mail -V");
|
have_mail = does_command_exist("mail -V");
|
||||||
if not have_mutt and not have_mail:
|
if not have_mutt and not have_mail:
|
||||||
log("ERROR: e-mail senders 'mail' or 'mutt' not found")
|
log("ERROR: e-mail senders 'mail' or 'mutt' not found")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
print "PARAMETERS:\nrepoURL=%s" % args.repoURL
|
print("PARAMETERS:\nrepoURL=%s" % args.repoURL)
|
||||||
print "test_path=%s" % test_path
|
print("test_path=%s" % test_path)
|
||||||
print "clone_path=%s" % clone_path
|
print("clone_path=%s" % clone_path)
|
||||||
print "testFilePath(%s)=%s" % (len(testFilePaths), testFilePaths)
|
print("testFilePath(%s)=%s" % (len(testFilePaths), testFilePaths))
|
||||||
print "message=%s" % args.message
|
print("message=%s" % args.message)
|
||||||
print "emails=%s" % args.emails
|
print("emails=%s" % args.emails)
|
||||||
print "maxLoadAvg=%s" % args.maxLoadAvg
|
print("maxLoadAvg=%s" % args.maxLoadAvg)
|
||||||
print "lowerLimit=%s" % args.lowerLimit
|
print("lowerLimit=%s" % args.lowerLimit)
|
||||||
print "lastCLevel=%s" % args.lastCLevel
|
print("lastCLevel=%s" % args.lastCLevel)
|
||||||
print "sleepTime=%s" % args.sleepTime
|
print("sleepTime=%s" % args.sleepTime)
|
||||||
print "dry_run=%s" % args.dry_run
|
print("dry_run=%s" % args.dry_run)
|
||||||
print "have_mutt=%s have_mail=%s" % (have_mutt, have_mail)
|
print("have_mutt=%s have_mail=%s" % (have_mutt, have_mail))
|
||||||
|
|
||||||
# clone ZSTD repo if needed
|
# clone ZSTD repo if needed
|
||||||
if not os.path.isdir(test_path):
|
if not os.path.isdir(test_path):
|
||||||
|
Loading…
Reference in New Issue
Block a user