BoDi icon indicating copy to clipboard operation
BoDi copied to clipboard

improve ctor and dispose

Open bollhals opened this issue 4 years ago • 0 comments

PR 6 extracted out of #40

Focused on the Ctor & Dispose methods

Main change:

  • Preallocate some space for the dictionaries so they don't have to do this on the first resolve.
  • Avoid closure allocation on dispose

Performance measurements:

For the first point it's hard to show benefits, except that preallocation is faster than grow the internal size of the dictionary multiple times.

For the 2nd bullet I've created a small test that just dispose the container, but I haven't added it, as I do not believe it really adds much value, but for the sake of completness:

Method Mean Error StdDev Min Max Median Rank Gen 0 Gen 1 Gen 2 Allocated
Current 155.3 ns 1.91 ns 1.79 ns 152.7 ns 158.4 ns 155.2 ns 1 0.0763 - - 360 B
Master 226.8 ns 1.24 ns 0.97 ns 224.8 ns 228.1 ns 226.9 ns 1 0.1223 - - 576 B

bollhals avatar May 01 '21 23:05 bollhals