SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

improve performance / reduce allocations of FireEvents

Open bollhals opened this issue 4 years ago • 3 comments

Various improvements around FireEvents

BindingRegistry

  • Change from List to Hashset to store Hookbindings for faster storage
  • reduced closure allocations by removing LINQ

RuntimeBinding*

  • Caching of lazy created objects like Parameter or Type
  • AsArray extension method => Avoid calling ToArray if it is already an array to reduce allocation
  • Throw on null in constructor and avoid check for null in hashcode (less branches equals faster hashcode)

TestExecutionEngine

  • Removed unused fields
  • GetExecuteArguments / ResolveArguments: remove LINQ and shortcut 0 length arguments
  • FireEvents: Shortcut no / one hook invoke path. Reduce / delay allocations where possible

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue).
  • [ ] New feature (non-breaking change which adds functionality).
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • [x] Performance improvement
  • [x] Refactoring (so no functional change)
  • [ ] Other (docs, build config, etc)

Checklist:

  • [ ] I've added tests for my code. (most of the time mandatory)
  • [ ] I have added an entry to the changelog. (mandatory)
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.

Proof [Before / After]

FireEvents FireEvents Before FireEvents After

GetExecuteArguments GetExecuteArguments Before GetExecuteArguments After

ResolveArguments ResolveArguments Before ResolveArguments After

bollhals avatar Apr 01 '21 21:04 bollhals

You are faster with sending new PRs then we with reviewing them. 😂

SabotageAndi avatar Apr 02 '21 06:04 SabotageAndi

You are faster with sending new PRs then we with reviewing them. 😂

I had a few hours to spare the last few days. 😊 Just take your time 👍🏼

bollhals avatar Apr 02 '21 07:04 bollhals

We will look at them next week.

SabotageAndi avatar Apr 02 '21 09:04 SabotageAndi