improve performance of antenna metrics calculation #2852
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Small refactoring so that the TerminalComponentModelerData class caches some results that are needed repeatedly for antenna metrics calculations
Greptile Overview
Updated On: 2025-09-29 19:23:47 UTC
Summary
This PR introduces performance optimizations to the antenna metrics calculation by implementing caching mechanisms in the
TerminalComponentModelerData
class. The key changes include:@cached_property
decorators forport_voltage_currents
,port_pseudo_waves
, andport_power_waves
to cache expensive computationsterminal_construct_smatrix
function now uses pre-computed cached wave amplitude data instead of recalculating it for each S-matrix construction_monitor_data_at_port_amplitude
method now takes an additionala_raw_port
parameter to avoid redundant calculationsThe caching strategy significantly reduces redundant calculations when multiple antenna metrics are computed, as the expensive port voltage/current and wave amplitude computations are now performed only once and reused across subsequent calls.
Confidence Score: 4/5
@cached_property
decorator. The logic changes are minimal and mostly involve using pre-computed cached results instead of recalculating them. The test updates are appropriate and maintain existing functionality. Two minor typos were found in docstrings.Important Files Changed
File Analysis
Sequence Diagram