Skip to content

Commit

Permalink
perf(planning_debug_tools): improve calculation time of perception_re…
Browse files Browse the repository at this point in the history
…producer

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
  • Loading branch information
takayuki5168 committed Dec 17, 2023
1 parent 90d5b94 commit 2d543fd
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ def on_timer(self):

# copy the messages
self.stopwatch.tic("message deepcopy")
msgs = pickle.loads(pickle.dumps(msgs_orig)) # this is x5 faster than deepcopy
objects_msg = msgs[0]
traffic_signals_msg = msgs[1]
if self.args.detected_object:
msgs = pickle.loads(pickle.dumps(msgs_orig)) # this is x5 faster than deepcopy
objects_msg = msgs[0]
traffic_signals_msg = msgs[1]
else:
# NOTE: No need to deepcopy since only timestamp will be changed and it will be changed every time correctly.
objects_msg = msgs_orig[0]
traffic_signals_msg = msgs_orig[1]

Check warning on line 94 in planning/planning_debug_tools/scripts/perception_replayer/perception_reproducer.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

PerceptionReproducer.on_timer increases in cyclomatic complexity from 12 to 14, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
self.stopwatch.toc("message deepcopy")

self.stopwatch.tic("transform and publish")
Expand Down

0 comments on commit 2d543fd

Please sign in to comment.