MetacoSA / NBitcoin

Comprehensive Bitcoin library for the .NET framework.
MIT License
1.88k stars 848 forks source link

Improve performance of Transaction parsing #1035

Closed NicolasDorier closed 3 years ago

NicolasDorier commented 3 years ago

This is done by making sure we pass the expected capacity when parsing a list. The code is a bit verbose, with some copy paste in BitcoinStream. But this is will worth the improvement.

Before Method Mean Error StdDev Median Rank
SerializeBigBlock 4.058 ms 0.0774 ms 0.0828 ms 4.076 ms 1
DeserializeBigBlock 6.362 ms 0.1230 ms 0.2827 ms 6.261 ms 2
After Method Mean Error StdDev Rank
SerializeBigBlock 3.661 ms 0.0714 ms 0.0850 ms 1
DeserializeBigBlock 5.505 ms 0.1076 ms 0.1105 ms 2