lisa.trace.MockTraceParser#
- class lisa.trace.MockTraceParser(*args, **kwargs)[source]#
Bases:
TraceParserBase
Mock parser that just returns the dataframes it was given.
- Parameters:
dfs (dict(str, pandas.DataFrame)) – Dictionary of
pandas.DataFrame
for each event that the parser can handle.path (str or None) – Useless for now, but it’s part of the Trace API, and it will be used for the dataframe cache as well.
events – Unused.
events – collections.abc.Iterable(str)
time_range (tuple(float, float)) – Time range of the trace in seconds. If not specified, the min and max timestamp of all
dfs
will be extracted, but it can lead to wrong analysis results (especially for signals that are not updated very often).
- Variable keyword arguments:
Forwarded to
TraceParserBase
As a subclass of
lisa.utils.PartialInit
, its constructor supports being applied to a partial set of parameters, leaving the rest to the internals oflisa.trace.Trace
:dfs = { 'sched_wakeup': pd.DataFrame.from_records( [ (0, 1, 1, 'task1', 'task1', 1, 1, 1), (1, 2, 1, 'task1', 'task1', 1, 1, 2), (2, 4, 2, 'task2', 'task2', 2, 1, 4), ], columns=('Time', '__cpu', '__pid', '__comm', 'comm', 'pid', 'prio', 'target_cpu'), index='Time', ), } trace = Trace(parser=MockTraceParser(dfs)) print(trace.df_event('sched_wakeup'))
Attributes
METADATA_KEYS
inheritedPossible metadata keys.
Properties
logger
inheritedConvenience short-hand for
self.get_logger()
.Methods
Return the metadata value.
Parse the given event from the trace and return a
pandas.DataFrame
with the following columns:.__enter__()
inherited__exit__()
inheritedfactory()
inheritedDecorator to use on alternative constructors, i.e. classmethods that return instances of the class.
get_all_metadata()
inheritedCollect all available metadata.
get_logger()
inheritedProvides a
logging.Logger
named aftercls
.get_parser_id()
inheritedGet the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.
log_locals()
inheritedDebugging aid: log the local variables of the calling function.
parse_all_events()
inheritedParse all available events.
parse_events()
inheritedSame as
parse_event()
but taking a list of events as input, and returning a mapping of event names topandas.DataFrame
for each.
Attributes#
- MockTraceParser.METADATA_KEYS = ['time-range', 'symbols-address', 'cpus-count', 'available-events', 'trace-id']#
Inherited attribute, see
lisa.trace.TraceParserBase.METADATA_KEYS
Possible metadata keys.
Properties#
- property MockTraceParser.logger#
Inherited property, see
lisa.utils.Loggable.logger
Convenience short-hand for
self.get_logger()
.
Methods#
- MockTraceParser.get_metadata(key)[source]#
Return the metadata value.
- Parameters:
key (str) –
Name of the metadata. Can be one of:
time-range
: tuple(start, end)
of the timestamps in the trace. This must be the first timestamp to appear in the trace, regardless of what events is being parsed. Otherwise, it would be impossible to use the time range of a parser in the motherTraceBase
when requesting specific events.symbols-address
: Dictionnary of address (int) to symbol names in the kernel (str) that was used to create the trace. This allows resolving the fields of events that recorded addresses rather than function names.cpus-count
: Number of CPUs on the system the trace was collected on.available-events
: List of all available events stored in the trace. The list must be exhaustive, not limited to the events that were requested. If an exhaustive list cannot be gathered, this metadata should not be implemented.trace-id
: Unique identifier for that trace file used tovalidate the cache. If not available, a checksum will be used.
- Raises:
MissingMetadataError
if the metadata is not available on that parser.
Note
A given metadata can only be expected to be available if asked for in the constructor, but bear in mind that there is no promise on the availability of any except for the following that must be provided if asked for:
time-range
Metadata may still be made available if not asked for, but only if it’s a very cheap byproduct of parsing that incurs no extra cost.
- MockTraceParser.parse_event(event)[source]#
Parse the given event from the trace and return a
pandas.DataFrame
with the following columns:Time
index: floating point absolute timestamp in seconds. The index must not have any duplicated values.One column per event field, with the appropriate dtype.
Columns prefixed with
__
: Header of each event, usually containing the following fields:__cpu
: CPU number the event was emitted from__pid
: PID of the current process scheduled at the time the event was emitted__comm
: Task command name going with__pid
at the point the event was emitted
- Parameters:
event (str) – name of the event to parse
- Raises:
MissingTraceEventError – If the event cannot be parsed.
Note
The caller is free to modify the index of the data, and it must not affect other dataframes.
- MockTraceParser.__enter__()#
Inherited method, see
lisa.trace.TraceParserBase.__enter__()
- MockTraceParser.__exit__(*args, **kwargs)#
Inherited method, see
lisa.trace.TraceParserBase.__exit__()
- classmethod MockTraceParser.factory(f)#
Inherited method, see
lisa.utils.PartialInit.factory()
Decorator to use on alternative constructors, i.e. classmethods that return instances of the class.
- MockTraceParser.get_all_metadata()#
Inherited method, see
lisa.trace.TraceParserBase.get_all_metadata()
Collect all available metadata.
- classmethod MockTraceParser.get_logger(suffix=None)#
Inherited method, see
lisa.utils.Loggable.get_logger()
Provides a
logging.Logger
named aftercls
.
- MockTraceParser.get_parser_id()#
Inherited method, see
lisa.trace.TraceParserBase.get_parser_id()
Get the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.
- classmethod MockTraceParser.log_locals(var_names=None, level='debug')#
Inherited method, see
lisa.utils.Loggable.log_locals()
Debugging aid: log the local variables of the calling function.
- MockTraceParser.parse_all_events()#
Inherited method, see
lisa.trace.TraceParserBase.parse_all_events()
Parse all available events.
- MockTraceParser.parse_events(events, best_effort=False, **kwargs)#
Inherited method, see
lisa.trace.TraceParserBase.parse_events()
Same as
parse_event()
but taking a list of events as input, and returning a mapping of event names topandas.DataFrame
for each.