Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rospy] Improve rospy.logXXX_throttle performance #1091

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions clients/rospy/src/rospy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,38 +181,37 @@ def __call__(self, caller_id, logging_func, period, msg):
_logging_throttle = LoggingThrottle()


def _frame_record_to_caller_id(frame_record):
frame, _, lineno, _, code, _ = frame_record
def _frame_to_caller_id(frame):
caller_id = (
inspect.getabsfile(frame),
lineno,
frame.f_lineno,
frame.f_lasti,
)
return pickle.dumps(caller_id)


def logdebug_throttle(period, msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_throttle(caller_id, logdebug, period, msg)


def loginfo_throttle(period, msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_throttle(caller_id, loginfo, period, msg)


def logwarn_throttle(period, msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_throttle(caller_id, logwarn, period, msg)


def logerr_throttle(period, msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_throttle(caller_id, logerr, period, msg)


def logfatal_throttle(period, msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_throttle(caller_id, logfatal, period, msg)


Expand All @@ -230,27 +229,27 @@ def __call__(self, caller_id, logging_func, msg):


def logdebug_once(msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_once(caller_id, logdebug, msg)


def loginfo_once(msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_once(caller_id, loginfo, msg)


def logwarn_once(msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_once(caller_id, logwarn, msg)


def logerr_once(msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_once(caller_id, logerr, msg)


def logfatal_once(msg):
caller_id = _frame_record_to_caller_id(inspect.stack()[1])
caller_id = _frame_to_caller_id(inspect.currentframe().f_back)
_logging_once(caller_id, logfatal, msg)


Expand Down