| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 1 | #! /usr/bin/env python |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 2 | |
| 3 | import argparse |
| 4 | import os |
| 5 | import string |
| 6 | import time |
| 7 | import traceback |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 8 | import subprocess |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 9 | |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 10 | default_repo_url = 'https://github.com/Cyan4973/zstd.git' |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 11 | working_dir_name = 'speedTest' |
| 12 | working_path = os.getcwd() + '/' + working_dir_name # /path/to/zstd/tests/speedTest |
| 13 | clone_path = working_path + '/' + 'zstd' # /path/to/zstd/tests/speedTest/zstd |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 14 | email_header = '[ZSTD_speedTest]' |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 15 | pid = str(os.getpid()) |
| 16 | |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 17 | |
| 18 | def log(text): |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 19 | print(time.strftime("%Y/%m/%d %H:%M:%S") + ' - ' + text) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 20 | |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 21 | |
| 22 | def execute(command, print_output=False, print_error=True, param_shell=True): |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 23 | log("> " + command) |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 24 | popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=param_shell, cwd=execute.cwd) |
| 25 | stdout = popen.communicate()[0] |
| 26 | stdout_lines = stdout.splitlines() |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 27 | if print_output: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 28 | print('\n'.join(stdout_lines)) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 29 | if popen.returncode is not None and popen.returncode != 0: |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 30 | if not print_output and print_error: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 31 | print('\n'.join(stdout_lines)) |
| 32 | raise RuntimeError('\n'.join(stdout_lines)) |
| 33 | return stdout_lines |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 34 | execute.cwd = None |
| 35 | |
| 36 | |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 37 | def does_command_exist(command): |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 38 | try: |
| 39 | execute(command, False, False); |
| 40 | except Exception as e: |
| 41 | return False |
| 42 | return True |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 43 | |
| 44 | |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 45 | def get_branches(): |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 46 | execute('git fetch -p') |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 47 | output = execute('git branch -rl') |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 48 | for line in output: |
| 49 | if "HEAD" in line: |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 50 | output.remove(line) # remove "origin/HEAD -> origin/dev" |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 51 | return map(lambda l: l.strip(), output) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 52 | |
| 53 | |
| 54 | def notify(branch, commit, last_commit): |
| 55 | text_tmpl = string.Template('Changes since $last_commit:\r\n$commits') |
| 56 | branch = branch.split('/')[1] |
| 57 | fmt = '--format="%h: (%an) %s, %ar"' |
| 58 | if last_commit is None: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 59 | commits = execute('git log -n 10 %s %s' % (fmt, commit)) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 60 | else: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 61 | commits = execute('git --no-pager log %s %s..%s' % (fmt, last_commit, commit)) |
| 62 | text = text_tmpl.substitute({'last_commit': last_commit, 'commits': '\n'.join(commits)}) |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 63 | print(str("commits for %s: %s" % (commit, text))) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 64 | |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 65 | |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 66 | def compile(branch, commit, dry_run): |
| 67 | local_branch = string.split(branch, '/')[1] |
| 68 | version = local_branch.rpartition('-')[2] |
| 69 | version = version + '_' + commit |
| 70 | execute('git checkout -- . && git checkout ' + branch) |
| 71 | if not dry_run: |
| 72 | execute('VERSION=' + version + '; make clean zstdprogram') |
| 73 | |
| 74 | |
| 75 | def get_last_commit(resultsFileName): |
| 76 | if not os.path.isfile(resultsFileName): |
| 77 | return None, None, None |
| 78 | commit = None |
| 79 | cspeed = [] |
| 80 | dspeed = [] |
| 81 | with open(resultsFileName,'r') as f: |
| 82 | for line in f: |
| 83 | words = line.split() |
| 84 | if len(words) == 2: # branch + commit |
| 85 | commit = words[1]; |
| 86 | cspeed = [] |
| 87 | dspeed = [] |
| 88 | if (len(words) == 8): |
| 89 | cspeed.append(float(words[3])) |
| 90 | dspeed.append(float(words[5])) |
| 91 | #if commit != None: |
| 92 | # print "commit=%s cspeed=%s dspeed=%s" % (commit, cspeed, dspeed) |
| 93 | return commit, cspeed, dspeed |
| 94 | |
| 95 | |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 96 | def benchmark_and_compare(branch, commit, resultsFileName, lastCLevel, testFilePath, fileName, last_cspeed, last_dspeed, lower_limit, maxLoadAvg, message): |
| 97 | sleepTime = 30 |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 98 | while os.getloadavg()[0] > maxLoadAvg: |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 99 | log("WARNING: bench loadavg=%.2f is higher than %s, sleeping for %s seconds" % (os.getloadavg()[0], maxLoadAvg, sleepTime)) |
| 100 | time.sleep(sleepTime) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 101 | start_load = str(os.getloadavg()) |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 102 | result = execute('programs/zstd -qi5b1e' + str(lastCLevel) + ' ' + testFilePath, print_output=True) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 103 | end_load = str(os.getloadavg()) |
| 104 | linesExpected = lastCLevel + 2; |
| 105 | if len(result) != linesExpected: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 106 | raise RuntimeError("ERROR: number of result lines=%d is different that expected %d" % (len(result), linesExpected)) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 107 | with open(resultsFileName, "a") as myfile: |
| 108 | myfile.write(branch + " " + commit + "\n") |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 109 | myfile.write('\n'.join(result) + '\n') |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 110 | myfile.close() |
| 111 | if (last_cspeed == None): |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 112 | log("WARNING: No data for comparison for branch=%s file=%s " % (branch, fileName)) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 113 | return "" |
| 114 | commit, cspeed, dspeed = get_last_commit(resultsFileName) |
| 115 | text = "" |
| 116 | for i in range(0, min(len(cspeed), len(last_cspeed))): |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 117 | print("%s: -%d cspeed=%6.2f clast=%6.2f cdiff=%1.4f dspeed=%6.2f dlast=%6.2f ddiff=%1.4f %s" % (branch, i+1, cspeed[i], last_cspeed[i], cspeed[i]/last_cspeed[i], dspeed[i], last_dspeed[i], dspeed[i]/last_dspeed[i], fileName)) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 118 | if (cspeed[i]/last_cspeed[i] < lower_limit): |
| 119 | text += "WARNING: File=%s level=%d cspeed=%s last=%s diff=%s\n" % (fileName, i+1, cspeed[i], last_cspeed[i], cspeed[i]/last_cspeed[i]) |
| 120 | if (dspeed[i]/last_dspeed[i] < lower_limit): |
| 121 | text += "WARNING: File=%s level=%d dspeed=%s last=%s diff=%s\n" % (fileName, i+1, dspeed[i], last_dspeed[i], dspeed[i]/last_dspeed[i]) |
| 122 | if text: |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 123 | text = message + ("\nmaxLoadAvg=%s load average at start=%s end=%s\n" % (maxLoadAvg, start_load, end_load)) + text |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 124 | return text |
| 125 | |
| 126 | |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 127 | def send_email(emails, topic, text, have_mutt, have_mail): |
| 128 | logFileName = working_path + '/' + 'tmpEmailContent' |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 129 | with open(logFileName, "w") as myfile: |
| 130 | myfile.writelines(text) |
| 131 | myfile.close() |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 132 | if have_mutt: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 133 | execute('mutt -s "' + topic + '" ' + emails + ' < ' + logFileName) |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 134 | elif have_mail: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 135 | execute('mail -s "' + topic + '" ' + emails + ' < ' + logFileName) |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 136 | else: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 137 | log("e-mail cannot be sent (mail or mutt not found)") |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 138 | |
| 139 | |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 140 | def send_email_with_attachments(branch, commit, last_commit, emails, text, results_files, logFileName, lower_limit, have_mutt, have_mail): |
| 141 | with open(logFileName, "w") as myfile: |
| 142 | myfile.writelines(text) |
| 143 | myfile.close() |
| 144 | email_topic = '%s:%s Warning for branch=%s commit=%s last_commit=%s speed<%s' % (email_header, pid, branch, commit, last_commit, lower_limit) |
| 145 | if have_mutt: |
| 146 | execute('mutt -s "' + email_topic + '" ' + emails + ' -a ' + results_files + ' < ' + logFileName) |
| 147 | elif have_mail: |
| 148 | execute('mail -s "' + email_topic + '" ' + emails + ' < ' + logFileName) |
| 149 | else: |
| 150 | log("e-mail cannot be sent (mail or mutt not found)") |
| 151 | |
| 152 | |
| 153 | def check_branch(branch, args, testFilePaths, have_mutt, have_mail): |
| 154 | commits = execute('git show -s --format=%h ' + branch)[0] |
| 155 | for commit in [commits]: |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 156 | try: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 157 | commitFileName = working_path + "/commit_" + branch.replace("/", "_") |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 158 | if os.path.isfile(commitFileName): |
| 159 | last_commit = file(commitFileName, 'r').read() |
| 160 | else: |
| 161 | last_commit = None |
| 162 | file(commitFileName, 'w').write(commit) |
| 163 | |
| 164 | if commit == last_commit: |
| 165 | log("skipping branch %s: head %s already processed" % (branch, commit)) |
| 166 | else: |
| 167 | log("build branch %s: head %s is different from prev %s" % (branch, commit, last_commit)) |
| 168 | compile(branch, commit, args.dry_run) |
| 169 | |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 170 | logFileName = working_path + "/log_" + branch.replace("/", "_") |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 171 | text_to_send = [] |
| 172 | results_files = "" |
| 173 | for filePath in testFilePaths: |
| 174 | fileName = filePath.rpartition('/')[2] |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 175 | resultsFileName = working_path + "/results_" + branch.replace("/", "_") + "_" + fileName |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 176 | last_commit, cspeed, dspeed = get_last_commit(resultsFileName) |
| 177 | |
| 178 | if not args.dry_run: |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 179 | text = benchmark_and_compare(branch, commit, resultsFileName, args.lastCLevel, filePath, fileName, cspeed, dspeed, args.lowerLimit, args.maxLoadAvg, args.message) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 180 | if text: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 181 | log("WARNING: redoing tests for branch %s: commit %s" % (branch, commit)) |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 182 | text = benchmark_and_compare(branch, commit, resultsFileName, args.lastCLevel, filePath, fileName, cspeed, dspeed, args.lowerLimit, args.maxLoadAvg, args.message) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 183 | if text: |
| 184 | text_to_send.append(text) |
| 185 | results_files += resultsFileName + " " |
| 186 | if text_to_send: |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 187 | send_email_with_attachments(branch, commit, last_commit, args.emails, text_to_send, results_files, logFileName, args.lowerLimit, have_mutt, have_mail) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 188 | notify(branch, commit, last_commit) |
| 189 | except Exception as e: |
| 190 | stack = traceback.format_exc() |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 191 | email_topic = '%s:%s ERROR in branch=%s commit=%s' % (email_header, pid, branch, commit) |
| 192 | send_email(args.emails, email_topic, stack, have_mutt, have_mail) |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 193 | print(stack) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 194 | |
| 195 | |
| 196 | if __name__ == '__main__': |
| 197 | parser = argparse.ArgumentParser() |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 198 | parser.add_argument('testFileNames', help='file names list for speed benchmark') |
| 199 | parser.add_argument('emails', help='list of e-mail addresses to send warnings') |
| inikep | 1e375f1 | 2016-06-13 10:50:09 +0200 | [diff] [blame] | 200 | parser.add_argument('--message', help='attach an additional message to e-mail', default="") |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 201 | parser.add_argument('--repoURL', help='changes default repository URL', default=default_repo_url) |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 202 | parser.add_argument('--lowerLimit', type=float, help='send email if speed is lower than given limit', default=0.98) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 203 | parser.add_argument('--maxLoadAvg', type=float, help='maximum load average to start testing', default=0.75) |
| 204 | parser.add_argument('--lastCLevel', type=int, help='last compression level for testing', default=5) |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 205 | parser.add_argument('--sleepTime', type=int, help='frequency of repository checking in seconds', default=300) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 206 | parser.add_argument('--dry-run', dest='dry_run', action='store_true', help='not build', default=False) |
| 207 | args = parser.parse_args() |
| 208 | |
| 209 | # check if test files are accessible |
| 210 | testFileNames = args.testFileNames.split() |
| 211 | testFilePaths = [] |
| 212 | for fileName in testFileNames: |
| 213 | if os.path.isfile(fileName): |
| 214 | testFilePaths.append(os.path.abspath(fileName)) |
| 215 | else: |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 216 | log("ERROR: File not found: " + fileName) |
| 217 | exit(1) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 218 | |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 219 | # check availability of e-mail senders |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 220 | have_mutt = does_command_exist("mutt -h"); |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 221 | have_mail = does_command_exist("mail -V"); |
| inikep | f169029 | 2016-06-10 13:59:08 +0200 | [diff] [blame] | 222 | if not have_mutt and not have_mail: |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 223 | log("ERROR: e-mail senders 'mail' or 'mutt' not found") |
| 224 | exit(1) |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 225 | |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 226 | print("PARAMETERS:\nrepoURL=%s" % args.repoURL) |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 227 | print("working_path=%s" % working_path) |
| inikep | 2d9272f | 2016-06-21 19:28:51 +0200 | [diff] [blame] | 228 | print("clone_path=%s" % clone_path) |
| 229 | print("testFilePath(%s)=%s" % (len(testFilePaths), testFilePaths)) |
| 230 | print("message=%s" % args.message) |
| 231 | print("emails=%s" % args.emails) |
| 232 | print("maxLoadAvg=%s" % args.maxLoadAvg) |
| 233 | print("lowerLimit=%s" % args.lowerLimit) |
| 234 | print("lastCLevel=%s" % args.lastCLevel) |
| 235 | print("sleepTime=%s" % args.sleepTime) |
| 236 | print("dry_run=%s" % args.dry_run) |
| 237 | print("have_mutt=%s have_mail=%s" % (have_mutt, have_mail)) |
| inikep | c1b154a | 2016-06-10 12:53:12 +0200 | [diff] [blame] | 238 | |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 239 | # clone ZSTD repo if needed |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 240 | if not os.path.isdir(working_path): |
| 241 | os.mkdir(working_path) |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 242 | if not os.path.isdir(clone_path): |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 243 | execute.cwd = working_path |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 244 | execute('git clone ' + args.repoURL) |
| 245 | if not os.path.isdir(clone_path): |
| 246 | log("ERROR: ZSTD clone not found: " + clone_path) |
| 247 | exit(1) |
| 248 | execute.cwd = clone_path |
| 249 | |
| 250 | # check if speedTest.pid already exists |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 251 | pidfile = "./speedTest.pid" |
| 252 | if os.path.isfile(pidfile): |
| 253 | log("ERROR: %s already exists, exiting" % pidfile) |
| 254 | exit(1) |
| 255 | |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 256 | send_email(args.emails, email_header + ':%s test-zstd-speed.py has been started' % pid, '', have_mutt, have_mail) |
| 257 | |
| 258 | file(pidfile, 'w').write(pid) |
| inikep | 9470b87 | 2016-06-09 12:54:06 +0200 | [diff] [blame] | 259 | while True: |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 260 | try: |
| 261 | loadavg = os.getloadavg()[0] |
| 262 | if (loadavg <= args.maxLoadAvg): |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 263 | branches = get_branches() |
| 264 | for branch in branches: |
| 265 | check_branch(branch, args, testFilePaths, have_mutt, have_mail) |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 266 | else: |
| 267 | log("WARNING: main loadavg=%.2f is higher than %s" % (loadavg, args.maxLoadAvg)) |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 268 | log("sleep for %s seconds" % args.sleepTime) |
| 269 | time.sleep(args.sleepTime) |
| inikep | d731de8 | 2016-06-21 11:26:17 +0200 | [diff] [blame] | 270 | finally: |
| 271 | os.unlink(pidfile) |
| inikep | 95da743 | 2016-06-22 12:12:35 +0200 | [diff] [blame^] | 272 | send_email(args.emails, email_header + ':%s test-zstd-speed.py has been stopped' % pid, '', have_mutt, have_mail) |