X-Git-Url: https://git.tld-linux.org/?p=TLD.git;a=blobdiff_plain;f=pld-builder.new%2FPLD_Builder%2Fstopwatch.py;fp=pld-builder.new%2FPLD_Builder%2Fstopwatch.py;h=0000000000000000000000000000000000000000;hp=151c164e4ff63bf8bc55b9950787b5b45cf40078;hb=3dc53b6865f716904ad4d02e934e04b3d4855c32;hpb=b235722fd546915a60800f2660d76f684d6f1445 diff --git a/pld-builder.new/PLD_Builder/stopwatch.py b/pld-builder.new/PLD_Builder/stopwatch.py deleted file mode 100644 index 151c164..0000000 --- a/pld-builder.new/PLD_Builder/stopwatch.py +++ /dev/null @@ -1,45 +0,0 @@ -# vi: encoding=utf-8 ts=8 sts=4 sw=4 et - -import time -import resource - -class Time: - def __init__(self): - x = resource.getrusage(resource.RUSAGE_CHILDREN) - self.user_time = x[0] - self.sys_time = x[1] - self.non_io_faults = x[6] - self.io_faults = x[7] - self.time = time.time() - - def sub(self, x): - self.user_time -= x.user_time - self.sys_time -= x.sys_time - self.non_io_faults -= x.non_io_faults - self.io_faults -= x.io_faults - self.time -= x.time - - def format(self): - return "user:%.2fs sys:%.2fs real:%.2fs (faults io:%d non-io:%d)" % \ - (self.user_time, self.sys_time, self.time, self.io_faults, - self.non_io_faults) - -class Timer: - def __init__(self): - self.starts = [] - - def start(self): - self.starts.append(Time()) - - def stop(self): - tmp = Time() - tmp.sub(self.starts.pop()) - return tmp.format() - -t = Timer() - -def start(): - t.start() - -def stop(): - return t.stop()