You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The initial XML reading to create objects can be slower than the actual packet parsing when there are a lot of parameters and items in the file. This is relevant for the CTIM file which has lots of parameters, a quick example script for testing:
frompathlibimportPathimporttimefromspace_packet_parserimportdefinitionsxtce_document=Path("tests/test_data/ctim/ctim_xtce_v1.xml")
start=time.time()
packet_definition=definitions.XtcePacketDefinition(xtce_document)
total_time=time.time() -startprint(f"It took {total_time:.2f} seconds to parse the XTCE document")
print("Number of containers:", len(packet_definition._sequence_container_cache))
print("Number of parameters:", len(packet_definition._parameter_cache))
print("Number of parameter types:", len(packet_definition._parameter_type_cache))
on main, it currently takes ~12.8s
It took 12.79 seconds to parse the XTCE document
Number of containers: 39
Number of parameters: 9491
Number of parameter types: 15
Profiling this, the slowdown in this case is in the _find_parameter() method. In there, an XML findall() call is issued for every parameter.
Implementation Plan
The findall() can be called just once to update the cache with all of the items rather than for each of the parameters iteratively as we go through the list. I propose to add a new _populate_parameter_cache() method that will get called during initialization, and then future lookups happen based on the cache rather than the _find_parameter() method.
The text was updated successfully, but these errors were encountered:
Context
The initial XML reading to create objects can be slower than the actual packet parsing when there are a lot of parameters and items in the file. This is relevant for the CTIM file which has lots of parameters, a quick example script for testing:
on main, it currently takes ~12.8s
Profiling this, the slowdown in this case is in the
_find_parameter()
method. In there, an XMLfindall()
call is issued for every parameter.Implementation Plan
The
findall()
can be called just once to update the cache with all of the items rather than for each of the parameters iteratively as we go through the list. I propose to add a new_populate_parameter_cache()
method that will get called during initialization, and then future lookups happen based on the cache rather than the_find_parameter()
method.The text was updated successfully, but these errors were encountered: