]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
bench.c: added support for ZSTD_GIT_COMMIT
authorinikep <inikep@gmail.com>
Wed, 22 Jun 2016 14:13:25 +0000 (16:13 +0200)
committerinikep <inikep@gmail.com>
Wed, 22 Jun 2016 14:13:25 +0000 (16:13 +0200)
programs/bench.c
tests/test-zstd-speed.py

index 81164e4291c194855b1a7a2e8e3699fe11a86586..a8fc7408a4248900fa6ccf4004a633a025e17581 100644 (file)
@@ -43,7 +43,9 @@
 *  Constants
 ***************************************/
 #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
 
 #define NBLOOPS               3
@@ -363,7 +365,7 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
     memset(&total, 0, sizeof(total));
 
     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;
 
index 075dd472badbab6db18e969bed0ff53d36a3f9c2..2382f231e43c7142394f5aaa34cf2d0b1835ea45 100755 (executable)
@@ -95,7 +95,7 @@ def compile(branch, commit, last_commit, dry_run):
     execute('git checkout -- . && git checkout ' + branch)
     print(git_get_changes(branch, commit, last_commit))
     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):
@@ -148,46 +148,44 @@ def benchmark_and_compare(branch, commit, resultsFileName, lastCLevel, testFileP
         return text
 
 
-def check_branch(branch, args, testFilePaths, have_mutt, have_mail):
-    commits = execute('git show -s --format=%h ' + branch)[0]
-    for commit in [commits]:
-        try:
-            last_commit = None
-            commitFileName = working_path + "/commit_" + branch.replace("/", "_")
-            if os.path.isfile(commitFileName):
-                last_commit = file(commitFileName, 'r').read()
-            file(commitFileName, 'w').write(commit)
-
-            if commit == last_commit:
-                log("skipping branch %s: head %s already processed" % (branch, commit))
-                continue
-
-            log("build branch %s: head %s is different from prev %s" % (branch, commit, last_commit))
-            compile(branch, commit, last_commit, args.dry_run)
-
-            logFileName = working_path + "/log_" + branch.replace("/", "_")
-            text_to_send = []
-            results_files = ""
-            for filePath in testFilePaths:
-                fileName = filePath.rpartition('/')[2]
-                resultsFileName = working_path + "/results_" + branch.replace("/", "_") + "_" + fileName
-                last_commit, cspeed, dspeed = get_last_results(resultsFileName)
-
-                if not args.dry_run:
+def check_commit(branch, commit, args, testFilePaths, have_mutt, have_mail):
+    try:
+        last_commit = None
+        commitFileName = working_path + "/commit_" + branch.replace("/", "_")
+        if os.path.isfile(commitFileName):
+            last_commit = file(commitFileName, 'r').read()
+        file(commitFileName, 'w').write(commit)
+
+        if commit == last_commit:
+            log("skipping branch %s: head %s already processed" % (branch, commit))
+            return
+
+        log("build branch %s: head %s is different from prev %s" % (branch, commit, last_commit))
+        compile(branch, commit, last_commit, args.dry_run)
+
+        logFileName = working_path + "/log_" + branch.replace("/", "_")
+        text_to_send = []
+        results_files = ""
+        for filePath in testFilePaths:
+            fileName = filePath.rpartition('/')[2]
+            resultsFileName = working_path + "/results_" + branch.replace("/", "_") + "_" + fileName
+            last_commit, cspeed, dspeed = get_last_results(resultsFileName)
+
+            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)
                     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)
-                        if text:
-                            text_to_send.append(text)
-                            results_files += resultsFileName + " "
-            if text_to_send:
-                send_email_with_attachments(branch, commit, last_commit, args.emails, text_to_send, results_files, logFileName, args.lowerLimit, have_mutt, have_mail)
-        except Exception as e:
-            stack = traceback.format_exc()
-            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)
+                        text_to_send.append(text)
+                        results_files += resultsFileName + " "
+        if text_to_send:
+            send_email_with_attachments(branch, commit, last_commit, args.emails, text_to_send, results_files, logFileName, args.lowerLimit, have_mutt, have_mail)
+    except Exception as e:
+        stack = traceback.format_exc()
+        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__':
@@ -259,7 +257,9 @@ if __name__ == '__main__':
             if (loadavg <= args.maxLoadAvg):
                 branches = git_get_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:
                 log("WARNING: main loadavg=%.2f is higher than %s" % (loadavg, args.maxLoadAvg))
             log("sleep for %s seconds" % args.sleepTime)