mirror of
https://git.yoctoproject.org/poky
synced 2026-09-29 07:36:20 +02:00
scripts/buildstats-diff: simplify timestamp handling
Simply use floats instead of datetime and timedelta objects for handling timestamps. (From OE-Core rev: d97c844f388bd4c52248fe597d5985ef20d5a96d) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
46ed698f05
commit
48f79758ea
@@ -22,7 +22,6 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from datetime import datetime, timedelta, tzinfo
|
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
@@ -35,38 +34,11 @@ class ScriptError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TimeZone(tzinfo):
|
|
||||||
"""Simple fixed-offset tzinfo"""
|
|
||||||
def __init__(self, seconds, name):
|
|
||||||
self._offset = timedelta(seconds=seconds)
|
|
||||||
self._name = name
|
|
||||||
|
|
||||||
def utcoffset(self, dt):
|
|
||||||
return self._offset
|
|
||||||
|
|
||||||
def tzname(self, dt):
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
def dst(self, dt):
|
|
||||||
return None
|
|
||||||
|
|
||||||
TIMEZONES = {'UTC': TimeZone(0, 'UTC'),
|
|
||||||
'EET': TimeZone(7200, 'EET'),
|
|
||||||
'EEST': TimeZone(10800, 'EEST')}
|
|
||||||
|
|
||||||
taskdiff_fields = ('pkg', 'pkg_op', 'task', 'task_op', 'value1', 'value2',
|
taskdiff_fields = ('pkg', 'pkg_op', 'task', 'task_op', 'value1', 'value2',
|
||||||
'absdiff', 'reldiff')
|
'absdiff', 'reldiff')
|
||||||
TaskDiff = namedtuple('TaskDiff', ' '.join(taskdiff_fields))
|
TaskDiff = namedtuple('TaskDiff', ' '.join(taskdiff_fields))
|
||||||
|
|
||||||
|
|
||||||
def to_datetime_obj(obj):
|
|
||||||
"""Helper for getting timestamps in datetime format"""
|
|
||||||
if isinstance(obj, datetime):
|
|
||||||
return obj
|
|
||||||
else:
|
|
||||||
return datetime.utcfromtimestamp(obj).replace(tzinfo=TIMEZONES['UTC'])
|
|
||||||
|
|
||||||
|
|
||||||
class BSTask(dict):
|
class BSTask(dict):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self['start_time'] = None
|
self['start_time'] = None
|
||||||
@@ -86,7 +58,7 @@ class BSTask(dict):
|
|||||||
@property
|
@property
|
||||||
def walltime(self):
|
def walltime(self):
|
||||||
"""Elapsed wall clock time"""
|
"""Elapsed wall clock time"""
|
||||||
return self['elapsed_time'].total_seconds()
|
return self['elapsed_time']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def read_bytes(self):
|
def read_bytes(self):
|
||||||
@@ -118,10 +90,10 @@ def read_buildstats_file(buildstat_file):
|
|||||||
key, val = line.split(':', 1)
|
key, val = line.split(':', 1)
|
||||||
val = val.strip()
|
val = val.strip()
|
||||||
if key == 'Started':
|
if key == 'Started':
|
||||||
start_time = to_datetime_obj(float(val))
|
start_time = float(val)
|
||||||
bs_task['start_time'] = start_time
|
bs_task['start_time'] = start_time
|
||||||
elif key == 'Ended':
|
elif key == 'Ended':
|
||||||
end_time = to_datetime_obj(float(val))
|
end_time = float(val)
|
||||||
elif key.startswith('IO '):
|
elif key.startswith('IO '):
|
||||||
split = key.split()
|
split = key.split()
|
||||||
bs_task['iostat'][split[1]] = int(val)
|
bs_task['iostat'][split[1]] = int(val)
|
||||||
|
|||||||
Reference in New Issue
Block a user