...
 
Commits (7)
......@@ -4,7 +4,7 @@
<name>tracetools_analysis</name>
<version>0.1.1</version>
<description>Tools for analysing trace data.</description>
<maintainer email="fixed-term.christophe.bourquebedard@de.bosch.com">Christophe Bedard</maintainer>
<maintainer email="bedard.christophe@gmail.com">Christophe Bedard</maintainer>
<maintainer email="ingo.luetkebohle@de.bosch.com">Ingo Lütkebohle</maintainer>
<license>Apache 2.0</license>
<author email="ingo.luetkebohle@de.bosch.com">Ingo Lütkebohle</author>
......@@ -16,6 +16,7 @@
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_xmllint</test_depend>
<test_depend>python3-pytest</test_depend>
<export>
......
......@@ -19,7 +19,7 @@ setup(
'Ingo Lütkebohle'
),
maintainer_email=(
'fixed-term.christophe.bourquebedard@de.bosch.com, '
'bedard.christophe@gmail.com, '
'ingo.luetkebohle@de.bosch.com'
),
author=(
......
# Copyright 2019 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ament_xmllint.main import main
import pytest
@pytest.mark.linter
@pytest.mark.xmllint
def test_xmllint():
rc = main(argv=[])
assert rc == 0, 'Found errors'
......@@ -49,7 +49,7 @@ class CpuTimeDataModel(DataModel):
'duration': duration,
'cpu_id': cpu_id,
}
self.times.loc[len(self.times.index)] = data
self.times = self.times.append(data, ignore_index=True)
def print_model(self) -> None:
"""Debug method to print every contained df."""
......
......@@ -59,7 +59,7 @@ class ProfileDataModel(DataModel):
'duration': duration,
'actual_duration': actual_duration,
}
self.times.loc[len(self.times.index)] = data
self.times = self.times.append(data, ignore_index=True)
def print_model(self) -> None:
"""Debug method to print every contained df."""
......
......@@ -143,7 +143,7 @@ class RosDataModel(DataModel):
'duration': duration,
'intra_process': intra_process,
}
self.callback_instances.loc[len(self.callback_instances.index)] = data
self.callback_instances = self.callback_instances.append(data, ignore_index=True)
def print_model(self) -> None:
"""Debug method to print every contained df."""
......
......@@ -15,6 +15,7 @@
"""Base processor module."""
from collections import defaultdict
import sys
from typing import Callable
from typing import Dict
from typing import List
......@@ -258,6 +259,9 @@ class Processor():
expanded_handlers = self._expand_dependencies(*handlers, **kwargs)
self._handler_multimap = self._get_handler_maps(expanded_handlers)
self._register_with_handlers(expanded_handlers)
self._progress_display = ProcessingProgressDisplay(
[type(handler).__name__ for handler in expanded_handlers],
)
@staticmethod
def _expand_dependencies(
......@@ -306,8 +310,10 @@ class Processor():
:param events: the events to process
"""
self._progress_display.set_work_total(len(events))
for event in events:
self._process_event(event)
self._progress_display.did_work()
def _process_event(self, event: DictEvent) -> None:
"""Process a single event."""
......@@ -339,3 +345,31 @@ class Processor():
raise_if_not_found=False)
metadata = EventMetadata(event_name, timestamp, cpu_id, procname, pid, tid)
handler_function(event, metadata)
class ProcessingProgressDisplay():
def __init__(
self,
processing_elements: List[str],
) -> None:
self.__info_string = '[' + ', '.join(processing_elements) + ']'
self.__progress_count = 0
self.__total_work = 0
self.__work_display_period = 1
def set_work_total(
self,
total: int,
) -> None:
self.__total_work = total
self.__work_display_period = int(self.__total_work / 100.0)
def did_work(
self,
increment: int = 1,
) -> None:
self.__progress_count += increment
if self.__progress_count % self.__work_display_period == 0:
percentage = 100.0 * (float(self.__progress_count) / float(self.__total_work))
sys.stdout.write(f' [{percentage:2.0f}%] {self.__info_string}\r')