-
Notifications
You must be signed in to change notification settings - Fork 60
Can we improve performance? #1537
Description
What is your question?
There are lots of places in the codebase where we initialise an empty list and then append items to that list, even though, in many cases, every element of the list is known from the start. For example, in vhdlFile (line 135):
lObjects = []
for sToken in lTokens:
lObjects.append(parser.item(sToken))This is inefficient, as the machine will need to move the object to new memory every time an item is appended. It is much more efficient to do this using a list comprehension.
lObjects = [parser.item(sToken) for sToken in lTokens]Performance is an issue for VSG. Part of this is just because it is written in Python, so it will naturally be slower than if it were written in a lower-level language like rust or C. However, I'd like to investigate whether we can improve performance somewhat with changes like these.
A quick test run with a long test file gave me the following results for the section above:
Before:
Time = 77612316 ns
Time = 78840997 ns
After:
Time = 77119071 ns
Time = 77136794 ns
Time = 76735795 ns
This suggests that there is a (small) performance improvement here. Maybe there are other places where we can get more performance improvements that will add up to something noticable.
I'm basically raising this issue to get a branch to facilitate these improvements/this investigation.
Metadata
Metadata
Assignees
Labels
Projects
Status