From 15f231a79320cbc97cd88d8a4751515a47ce223e Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Thu, 25 Apr 2013 13:43:49 -0700 Subject: Bug fixes from testing. --- parse/sched.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'parse') diff --git a/parse/sched.py b/parse/sched.py index 1033989..5a36da9 100644 --- a/parse/sched.py +++ b/parse/sched.py @@ -26,9 +26,11 @@ ScaleData = namedtuple('ScaleData', ['reg_tasks', 'base_tasks']) class TimeTracker: '''Store stats for durations of time demarcated by sched_trace records.''' - def __init__(self): + def __init__(self, join_job = False): self.begin = self.avg = self.max = self.num = self.next_job = 0 + self.join_job = join_job + # Count of times the job in start_time matched that in store_time self.matches = 0 # And the times it didn't @@ -39,9 +41,12 @@ class TimeTracker: # any task is always skipped self.last_record = None + self.stored_dur = 0 + def store_time(self, next_record): '''End duration of time.''' - dur = (self.last_record.when - self.begin) if self.last_record else -1 + dur = (self.last_record.when - self.begin) if self.last_record else -1 + dur += self.stored_dur if self.next_job == next_record.job: self.last_record = next_record @@ -49,13 +54,16 @@ class TimeTracker: if self.last_record: self.matches += 1 - if dur > 0: + if self.join_job and self.next_job == self.last_record.job: + self.stored_dur += dur + elif dur > 0: self.max = max(self.max, dur) self.avg *= float(self.num / (self.num + 1)) self.num += 1 self.avg += dur / float(self.num) self.begin = 0 + self.stored_dur = 0 self.next_job = 0 else: self.disjoints += 1 @@ -70,7 +78,6 @@ class TimeTracker: self.next_job = record.job - class LeveledArray(object): """Groups statistics by the level of the task to which they apply""" def __init__(self): -- cgit v1.2.2