1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

bench.c: added support for ZSTD_GIT_COMMIT

This commit is contained in:
inikep
2016-06-22 16:13:25 +02:00
parent f2f59d758e
commit d7d251ccb5
2 changed files with 40 additions and 38 deletions

View File

@ -43,7 +43,9 @@
* Constants * Constants
***************************************/ ***************************************/
#ifndef ZSTD_GIT_COMMIT #ifndef ZSTD_GIT_COMMIT
# define ZSTD_GIT_COMMIT "" # define ZSTD_GIT_COMMIT_STRING ""
#else
# define ZSTD_GIT_COMMIT_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_GIT_COMMIT)
#endif #endif
#define NBLOOPS 3 #define NBLOOPS 3
@ -363,7 +365,7 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
memset(&total, 0, sizeof(total)); memset(&total, 0, sizeof(total));
if (g_displayLevel == 1 && !g_additionalParam) if (g_displayLevel == 1 && !g_additionalParam)
DISPLAY("bench %s %s: input %u bytes, %i iterations, %u KB blocks\n", ZSTD_VERSION_STRING, ZSTD_GIT_COMMIT, (U32)benchedSize, g_nbIterations, (U32)(g_blockSize>>10)); DISPLAY("bench %s %s: input %u bytes, %i iterations, %u KB blocks\n", ZSTD_VERSION_STRING, ZSTD_GIT_COMMIT_STRING, (U32)benchedSize, g_nbIterations, (U32)(g_blockSize>>10));
if (cLevelLast < cLevel) cLevelLast = cLevel; if (cLevelLast < cLevel) cLevelLast = cLevel;

View File

@ -95,7 +95,7 @@ def compile(branch, commit, last_commit, dry_run):
execute('git checkout -- . && git checkout ' + branch) execute('git checkout -- . && git checkout ' + branch)
print(git_get_changes(branch, commit, last_commit)) print(git_get_changes(branch, commit, last_commit))
if not dry_run: if not dry_run:
execute('make clean zstdprogram MOREFLAGS="-DZSTD_GIT_COMMIT=%s"' % version, print_output=True) execute('make clean zstdprogram MOREFLAGS="-DZSTD_GIT_COMMIT=%s"' % version)
def get_last_results(resultsFileName): def get_last_results(resultsFileName):
@ -148,46 +148,44 @@ def benchmark_and_compare(branch, commit, resultsFileName, lastCLevel, testFileP
return text return text
def check_branch(branch, args, testFilePaths, have_mutt, have_mail): def check_commit(branch, commit, args, testFilePaths, have_mutt, have_mail):
commits = execute('git show -s --format=%h ' + branch)[0] try:
for commit in [commits]: last_commit = None
try: commitFileName = working_path + "/commit_" + branch.replace("/", "_")
last_commit = None if os.path.isfile(commitFileName):
commitFileName = working_path + "/commit_" + branch.replace("/", "_") last_commit = file(commitFileName, 'r').read()
if os.path.isfile(commitFileName): file(commitFileName, 'w').write(commit)
last_commit = file(commitFileName, 'r').read()
file(commitFileName, 'w').write(commit)
if commit == last_commit: if commit == last_commit:
log("skipping branch %s: head %s already processed" % (branch, commit)) log("skipping branch %s: head %s already processed" % (branch, commit))
continue return
log("build branch %s: head %s is different from prev %s" % (branch, commit, last_commit)) log("build branch %s: head %s is different from prev %s" % (branch, commit, last_commit))
compile(branch, commit, last_commit, args.dry_run) compile(branch, commit, last_commit, args.dry_run)
logFileName = working_path + "/log_" + branch.replace("/", "_") logFileName = working_path + "/log_" + branch.replace("/", "_")
text_to_send = [] text_to_send = []
results_files = "" results_files = ""
for filePath in testFilePaths: for filePath in testFilePaths:
fileName = filePath.rpartition('/')[2] fileName = filePath.rpartition('/')[2]
resultsFileName = working_path + "/results_" + branch.replace("/", "_") + "_" + fileName resultsFileName = working_path + "/results_" + branch.replace("/", "_") + "_" + fileName
last_commit, cspeed, dspeed = get_last_results(resultsFileName) last_commit, cspeed, dspeed = get_last_results(resultsFileName)
if not args.dry_run: if not args.dry_run:
text = benchmark_and_compare(branch, commit, resultsFileName, args.lastCLevel, filePath, fileName, cspeed, dspeed, args.lowerLimit, args.maxLoadAvg, args.message)
if text:
log("WARNING: redoing tests for branch %s: commit %s" % (branch, commit))
text = benchmark_and_compare(branch, commit, resultsFileName, args.lastCLevel, filePath, fileName, cspeed, dspeed, args.lowerLimit, args.maxLoadAvg, args.message) text = benchmark_and_compare(branch, commit, resultsFileName, args.lastCLevel, filePath, fileName, cspeed, dspeed, args.lowerLimit, args.maxLoadAvg, args.message)
if text: if text:
log("WARNING: redoing tests for branch %s: commit %s" % (branch, commit)) text_to_send.append(text)
text = benchmark_and_compare(branch, commit, resultsFileName, args.lastCLevel, filePath, fileName, cspeed, dspeed, args.lowerLimit, args.maxLoadAvg, args.message) results_files += resultsFileName + " "
if text: if text_to_send:
text_to_send.append(text) send_email_with_attachments(branch, commit, last_commit, args.emails, text_to_send, results_files, logFileName, args.lowerLimit, have_mutt, have_mail)
results_files += resultsFileName + " " except Exception as e:
if text_to_send: stack = traceback.format_exc()
send_email_with_attachments(branch, commit, last_commit, args.emails, text_to_send, results_files, logFileName, args.lowerLimit, have_mutt, have_mail) email_topic = '%s:%s ERROR in %s:%s' % (email_header, pid, branch, commit)
except Exception as e: send_email(args.emails, email_topic, stack, have_mutt, have_mail)
stack = traceback.format_exc() print(stack)
email_topic = '%s:%s ERROR in %s:%s' % (email_header, pid, branch, commit)
send_email(args.emails, email_topic, stack, have_mutt, have_mail)
print(stack)
if __name__ == '__main__': if __name__ == '__main__':
@ -259,7 +257,9 @@ if __name__ == '__main__':
if (loadavg <= args.maxLoadAvg): if (loadavg <= args.maxLoadAvg):
branches = git_get_branches() branches = git_get_branches()
for branch in branches: for branch in branches:
check_branch(branch, args, testFilePaths, have_mutt, have_mail) commits = execute('git show -s --format=%h ' + branch)[0]
for commit in [commits]:
check_commit(branch, commit, args, testFilePaths, have_mutt, have_mail)
else: else:
log("WARNING: main loadavg=%.2f is higher than %s" % (loadavg, args.maxLoadAvg)) log("WARNING: main loadavg=%.2f is higher than %s" % (loadavg, args.maxLoadAvg))
log("sleep for %s seconds" % args.sleepTime) log("sleep for %s seconds" % args.sleepTime)