tests: make fork_histogram optional

issue510
David Wilson 6 years ago
parent 17eff064b0
commit 4256d2aa4b

@ -27,6 +27,7 @@ class CallbackModule(ansible.plugins.callback.CallbackBase):
self.hist = hdrh.histogram.HdrHistogram(1, int(1e6*60), 3) self.hist = hdrh.histogram.HdrHistogram(1, int(1e6*60), 3)
self.fork_latency_sum_usec = 0.0 self.fork_latency_sum_usec = 0.0
if 'FORK_HISTOGRAM' in os.environ:
self.install() self.install()
def install(self): def install(self):
@ -53,6 +54,9 @@ class CallbackModule(ansible.plugins.callback.CallbackBase):
self.hist.record_value(latency_usec) self.hist.record_value(latency_usec)
def playbook_on_stats(self, stats): def playbook_on_stats(self, stats):
if 'FORK_HISTOGRAM' not in os.environ:
return
self_faults = get_fault_count(resource.RUSAGE_SELF) - self.faults_at_start self_faults = get_fault_count(resource.RUSAGE_SELF) - self.faults_at_start
child_faults = get_fault_count() child_faults = get_fault_count()
run_duration_sec = time.time() - self.run_start_time run_duration_sec = time.time() - self.run_start_time

Loading…
Cancel
Save