+15
-3
@@ -199,6 +199,18 @@ UTIL_STATIC U32 UTIL_isDirectory(const char* infilename)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A modified version of realloc().
|
||||||
|
* If UTIL_realloc() fails the original block is freed.
|
||||||
|
*/
|
||||||
|
UTIL_STATIC void *UTIL_realloc(void *ptr, size_t size)
|
||||||
|
{
|
||||||
|
void *newptr = realloc(ptr, size);
|
||||||
|
if (newptr) return newptr;
|
||||||
|
free(ptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define UTIL_HAS_CREATEFILELIST
|
# define UTIL_HAS_CREATEFILELIST
|
||||||
@@ -245,7 +257,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_
|
|||||||
else if ((cFile.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) || (cFile.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) || (cFile.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED)) {
|
else if ((cFile.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) || (cFile.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) || (cFile.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED)) {
|
||||||
if (*bufStart + *pos + pathLength >= *bufEnd) {
|
if (*bufStart + *pos + pathLength >= *bufEnd) {
|
||||||
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
|
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
|
||||||
*bufStart = (char*)realloc(*bufStart, newListSize);
|
*bufStart = (char*)UTIL_realloc(*bufStart, newListSize);
|
||||||
*bufEnd = *bufStart + newListSize;
|
*bufEnd = *bufStart + newListSize;
|
||||||
if (*bufStart == NULL) { free(path); FindClose(hFile); return 0; }
|
if (*bufStart == NULL) { free(path); FindClose(hFile); return 0; }
|
||||||
}
|
}
|
||||||
@@ -300,7 +312,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_
|
|||||||
} else {
|
} else {
|
||||||
if (*bufStart + *pos + pathLength >= *bufEnd) {
|
if (*bufStart + *pos + pathLength >= *bufEnd) {
|
||||||
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
|
ptrdiff_t newListSize = (*bufEnd - *bufStart) + LIST_SIZE_INCREASE;
|
||||||
*bufStart = (char*)realloc(*bufStart, newListSize);
|
*bufStart = (char*)UTIL_realloc(*bufStart, newListSize);
|
||||||
*bufEnd = *bufStart + newListSize;
|
*bufEnd = *bufStart + newListSize;
|
||||||
if (*bufStart == NULL) { free(path); closedir(dir); return 0; }
|
if (*bufStart == NULL) { free(path); closedir(dir); return 0; }
|
||||||
}
|
}
|
||||||
@@ -356,7 +368,7 @@ UTIL_STATIC const char** UTIL_createFileList(const char **inputNames, unsigned i
|
|||||||
size_t len = strlen(inputNames[i]);
|
size_t len = strlen(inputNames[i]);
|
||||||
if (buf + pos + len >= bufend) {
|
if (buf + pos + len >= bufend) {
|
||||||
ptrdiff_t newListSize = (bufend - buf) + LIST_SIZE_INCREASE;
|
ptrdiff_t newListSize = (bufend - buf) + LIST_SIZE_INCREASE;
|
||||||
buf = (char*)realloc(buf, newListSize);
|
buf = (char*)UTIL_realloc(buf, newListSize);
|
||||||
bufend = buf + newListSize;
|
bufend = buf + newListSize;
|
||||||
if (!buf) return NULL;
|
if (!buf) return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-15
@@ -9,6 +9,10 @@
|
|||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
# of patent rights can be found in the PATENTS file in the same directory.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Limitations:
|
||||||
|
# - doesn't support filenames with spaces
|
||||||
|
# - dir1/zstd and dir2/zstd will be merged in a single results file
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import string
|
import string
|
||||||
@@ -17,7 +21,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
script_version = 'v1.0.0 (2016-09-12)'
|
script_version = 'v1.0.1 (2016-09-15)'
|
||||||
default_repo_url = 'https://github.com/facebook/zstd.git'
|
default_repo_url = 'https://github.com/facebook/zstd.git'
|
||||||
working_dir_name = 'speedTest'
|
working_dir_name = 'speedTest'
|
||||||
working_path = os.getcwd() + '/' + working_dir_name # /path/to/zstd/tests/speedTest
|
working_path = os.getcwd() + '/' + working_dir_name # /path/to/zstd/tests/speedTest
|
||||||
@@ -130,7 +134,7 @@ def get_last_results(resultsFileName):
|
|||||||
csize = []
|
csize = []
|
||||||
cspeed = []
|
cspeed = []
|
||||||
dspeed = []
|
dspeed = []
|
||||||
if (len(words) == 8): # results
|
if (len(words) == 8) or (len(words) == 9): # results: "filename" or "XX files"
|
||||||
csize.append(int(words[1]))
|
csize.append(int(words[1]))
|
||||||
cspeed.append(float(words[3]))
|
cspeed.append(float(words[3]))
|
||||||
dspeed.append(float(words[5]))
|
dspeed.append(float(words[5]))
|
||||||
@@ -145,8 +149,10 @@ def benchmark_and_compare(branch, commit, last_commit, args, executableName, md5
|
|||||||
% (os.getloadavg()[0], args.maxLoadAvg, sleepTime))
|
% (os.getloadavg()[0], args.maxLoadAvg, sleepTime))
|
||||||
time.sleep(sleepTime)
|
time.sleep(sleepTime)
|
||||||
start_load = str(os.getloadavg())
|
start_load = str(os.getloadavg())
|
||||||
result = execute('programs/%s -qi5b1e%s %s' % (executableName, args.lastCLevel, testFilePath),
|
if args.dictionary:
|
||||||
print_output=True)
|
result = execute('programs/%s -rqi5b1e%s -D %s %s' % (executableName, args.lastCLevel, args.dictionary, testFilePath), print_output=True)
|
||||||
|
else:
|
||||||
|
result = execute('programs/%s -rqi5b1e%s %s' % (executableName, args.lastCLevel, testFilePath), print_output=True)
|
||||||
end_load = str(os.getloadavg())
|
end_load = str(os.getloadavg())
|
||||||
linesExpected = args.lastCLevel + 1
|
linesExpected = args.lastCLevel + 1
|
||||||
if len(result) != linesExpected:
|
if len(result) != linesExpected:
|
||||||
@@ -198,8 +204,7 @@ def test_commit(branch, commit, last_commit, args, testFilePaths, have_mutt, hav
|
|||||||
if not args.dry_run:
|
if not args.dry_run:
|
||||||
execute('make -C programs clean zstd CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion -DZSTD_GIT_COMMIT=%s" && ' % version +
|
execute('make -C programs clean zstd CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion -DZSTD_GIT_COMMIT=%s" && ' % version +
|
||||||
'mv programs/zstd programs/zstd_clang && ' +
|
'mv programs/zstd programs/zstd_clang && ' +
|
||||||
'make -C programs clean zstd MOREFLAGS="-DZSTD_GIT_COMMIT=%s" && ' % version +
|
'make -C programs clean zstd zstd32 MOREFLAGS="-DZSTD_GIT_COMMIT=%s"' % version)
|
||||||
'make -B -C programs zstd32 MOREFLAGS="-DZSTD_GIT_COMMIT=%s"' % version)
|
|
||||||
md5_zstd = hashfile(hashlib.md5(), clone_path + '/programs/zstd')
|
md5_zstd = hashfile(hashlib.md5(), clone_path + '/programs/zstd')
|
||||||
md5_zstd32 = hashfile(hashlib.md5(), clone_path + '/programs/zstd32')
|
md5_zstd32 = hashfile(hashlib.md5(), clone_path + '/programs/zstd32')
|
||||||
md5_zstd_clang = hashfile(hashlib.md5(), clone_path + '/programs/zstd_clang')
|
md5_zstd_clang = hashfile(hashlib.md5(), clone_path + '/programs/zstd_clang')
|
||||||
@@ -209,9 +214,17 @@ def test_commit(branch, commit, last_commit, args, testFilePaths, have_mutt, hav
|
|||||||
logFileName = working_path + "/log_" + branch.replace("/", "_") + ".txt"
|
logFileName = working_path + "/log_" + branch.replace("/", "_") + ".txt"
|
||||||
text_to_send = []
|
text_to_send = []
|
||||||
results_files = ""
|
results_files = ""
|
||||||
|
if args.dictionary:
|
||||||
|
dictName = args.dictionary.rpartition('/')[2]
|
||||||
|
else:
|
||||||
|
dictName = None
|
||||||
|
|
||||||
for filePath in testFilePaths:
|
for filePath in testFilePaths:
|
||||||
fileName = filePath.rpartition('/')[2]
|
fileName = filePath.rpartition('/')[2]
|
||||||
resultsFileName = working_path + "/results_" + branch.replace("/", "_") + "_" + fileName.replace(".", "_") + ".txt"
|
if dictName:
|
||||||
|
resultsFileName = working_path + "/" + dictName.replace(".", "_") + "_" + branch.replace("/", "_") + "_" + fileName.replace(".", "_") + ".txt"
|
||||||
|
else:
|
||||||
|
resultsFileName = working_path + "/results_" + branch.replace("/", "_") + "_" + fileName.replace(".", "_") + ".txt"
|
||||||
text = double_check(branch, commit, args, 'zstd', md5_zstd, 'gcc_version='+gcc_version, resultsFileName, filePath, fileName)
|
text = double_check(branch, commit, args, 'zstd', md5_zstd, 'gcc_version='+gcc_version, resultsFileName, filePath, fileName)
|
||||||
if text:
|
if text:
|
||||||
text_to_send.append(text)
|
text_to_send.append(text)
|
||||||
@@ -232,17 +245,18 @@ def test_commit(branch, commit, last_commit, args, testFilePaths, have_mutt, hav
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('testFileNames', help='file names list for speed benchmark')
|
parser.add_argument('testFileNames', help='file or directory names list for speed benchmark')
|
||||||
parser.add_argument('emails', help='list of e-mail addresses to send warnings')
|
parser.add_argument('emails', help='list of e-mail addresses to send warnings')
|
||||||
parser.add_argument('--message', help='attach an additional message to e-mail', default="")
|
parser.add_argument('--dictionary', '-D', help='path to the dictionary')
|
||||||
|
parser.add_argument('--message', '-m', help='attach an additional message to e-mail', default="")
|
||||||
parser.add_argument('--repoURL', help='changes default repository URL', default=default_repo_url)
|
parser.add_argument('--repoURL', help='changes default repository URL', default=default_repo_url)
|
||||||
parser.add_argument('--lowerLimit', type=float, help='send email if speed is lower than given limit', default=0.98)
|
parser.add_argument('--lowerLimit', '-l', type=float, help='send email if speed is lower than given limit', default=0.98)
|
||||||
parser.add_argument('--ratioLimit', type=float, help='send email if ratio is lower than given limit', default=0.999)
|
parser.add_argument('--ratioLimit', '-r', type=float, help='send email if ratio is lower than given limit', default=0.999)
|
||||||
parser.add_argument('--maxLoadAvg', type=float, help='maximum load average to start testing', default=0.75)
|
parser.add_argument('--maxLoadAvg', type=float, help='maximum load average to start testing', default=0.75)
|
||||||
parser.add_argument('--lastCLevel', type=int, help='last compression level for testing', default=5)
|
parser.add_argument('--lastCLevel', type=int, help='last compression level for testing', default=5)
|
||||||
parser.add_argument('--sleepTime', type=int, help='frequency of repository checking in seconds', default=300)
|
parser.add_argument('--sleepTime', '-s', type=int, help='frequency of repository checking in seconds', default=300)
|
||||||
parser.add_argument('--dry-run', dest='dry_run', action='store_true', help='not build', default=False)
|
parser.add_argument('--dry-run', dest='dry_run', action='store_true', help='not build', default=False)
|
||||||
parser.add_argument('--verbose', action='store_true', help='more verbose logs', default=False)
|
parser.add_argument('--verbose', '-v', action='store_true', help='more verbose logs', default=False)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
verbose = args.verbose
|
verbose = args.verbose
|
||||||
|
|
||||||
@@ -251,10 +265,17 @@ if __name__ == '__main__':
|
|||||||
testFilePaths = []
|
testFilePaths = []
|
||||||
for fileName in testFileNames:
|
for fileName in testFileNames:
|
||||||
fileName = os.path.expanduser(fileName)
|
fileName = os.path.expanduser(fileName)
|
||||||
if os.path.isfile(fileName):
|
if os.path.isfile(fileName) or os.path.isdir(fileName):
|
||||||
testFilePaths.append(os.path.abspath(fileName))
|
testFilePaths.append(os.path.abspath(fileName))
|
||||||
else:
|
else:
|
||||||
log("ERROR: File not found: " + fileName)
|
log("ERROR: File/directory not found: " + fileName)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# check if dictionary is accessible
|
||||||
|
if args.dictionary:
|
||||||
|
args.dictionary = os.path.abspath(os.path.expanduser(args.dictionary))
|
||||||
|
if not os.path.isfile(args.dictionary):
|
||||||
|
log("ERROR: Dictionary not found: " + args.dictionary)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# check availability of e-mail senders
|
# check availability of e-mail senders
|
||||||
@@ -274,6 +295,7 @@ if __name__ == '__main__':
|
|||||||
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("dictionary=%s" % args.dictionary)
|
||||||
print("maxLoadAvg=%s" % args.maxLoadAvg)
|
print("maxLoadAvg=%s" % args.maxLoadAvg)
|
||||||
print("lowerLimit=%s" % args.lowerLimit)
|
print("lowerLimit=%s" % args.lowerLimit)
|
||||||
print("ratioLimit=%s" % args.ratioLimit)
|
print("ratioLimit=%s" % args.ratioLimit)
|
||||||
|
|||||||
Reference in New Issue
Block a user