# # # patch "mtn_benchmark/instrumenters.py" # from [9a66e206152fda90931e18daeab2ba118a29919c] # to [d14612afa3e3d07aa04c9f93c476c5255ae8ce24] # ============================================================ --- mtn_benchmark/instrumenters.py 9a66e206152fda90931e18daeab2ba118a29919c +++ mtn_benchmark/instrumenters.py d14612afa3e3d07aa04c9f93c476c5255ae8ce24 @@ -22,21 +22,24 @@ class TimingInstrumenterObj(instrumenter return float(s) def run_bg(self, name, scratchdir, cmd): - # We put a noticable string "DATA" at the start of the format, so that - # we can find it even if time(1) decides to print other garbage, like - # "Command exited with non-zero status 1". - my_cmd = ["time", "-f", "DATA: %U %S %E", - "-o", os.path.join(scratchdir, "timings-" + name)] + cmd + if os.popen("uname -a").read().startswith("FreeBSD"): + my_cmd = ["time", + "-o", os.path.join(scratchdir, "timings-" + name)] + cmd + else: + my_cmd = ["time", "-f", " %E real %U user %S sys", + "-o", os.path.join(scratchdir, "timings-" + name)] + cmd def timing_hook(pid): timing_file = open(os.path.join(scratchdir, "timings-" + name), "r") for line in timing_file: - if line.startswith("DATA"): + if "real" in line: break - assert line.startswith("DATA") - junk, user, sys, wall = line.split() + real, real_s, user, user_s, sys, sys_s = line.split() + assert real_s == "real" + assert user_s == "user" + assert sys_s == "sys" self.record_stat(name + "-user-time", self.parse_time_str(user)) self.record_stat(name + "-system-time", self.parse_time_str(sys)) - self.record_stat(name + "-wall-time", self.parse_time_str(wall)) + self.record_stat(name + "-wall-time", self.parse_time_str(real)) process = super(TimingInstrumenterObj, self).run_bg(name, scratchdir, my_cmd) process.hook(timing_hook) return process