mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-21 20:38:57 +00:00
framework/job: track run time.
Job now tracks how long it took to run the workload and save the timedelta value in the run_time attribute.
This commit is contained in:
parent
2ef4074c8b
commit
1e233d2104
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from wa.framework import pluginloader, signal
|
from wa.framework import pluginloader, signal
|
||||||
from wa.framework.configuration.core import Status
|
from wa.framework.configuration.core import Status
|
||||||
@ -37,6 +38,7 @@ class Job(object):
|
|||||||
self.context = context
|
self.context = context
|
||||||
self.workload = None
|
self.workload = None
|
||||||
self.output = None
|
self.output = None
|
||||||
|
self.run_time = None
|
||||||
self.retries = 0
|
self.retries = 0
|
||||||
self._status = Status.NEW
|
self._status = Status.NEW
|
||||||
|
|
||||||
@ -71,7 +73,11 @@ class Job(object):
|
|||||||
def run(self, context):
|
def run(self, context):
|
||||||
self.logger.info('Running job {}'.format(self.id))
|
self.logger.info('Running job {}'.format(self.id))
|
||||||
with signal.wrap('WORKLOAD_EXECUTION', self, context):
|
with signal.wrap('WORKLOAD_EXECUTION', self, context):
|
||||||
self.workload.run(context)
|
start_time = datetime.utcnow()
|
||||||
|
try:
|
||||||
|
self.workload.run(context)
|
||||||
|
finally:
|
||||||
|
self.run_time = datetime.utcnow() - start_time
|
||||||
|
|
||||||
def process_output(self, context):
|
def process_output(self, context):
|
||||||
self.logger.info('Processing output for job {}'.format(self.id))
|
self.logger.info('Processing output for job {}'.format(self.id))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user