burakoner / OKEx.Net

Open source .Net API wrapper for the @OKEx V5 Rest API and V5 Websocket API
MIT License
86 stars 48 forks source link

Optimise OkexMessageMatchesHandler #15

Closed tekr closed 3 years ago

tekr commented 3 years ago

Fixes #14. Updated profiling results below show method reduced to ~2% CPU.

MatchesHanderCostPostOptimisation

tekr commented 3 years ago

Note that this PR replaces a number of calls to string.BeginsWith() with string.Equals() as part of the performance improvements.

Based on the OkEx API docs and all examples within it, as well as empirical testing, there are no cases where Equals() would return a different result than BeginsWith(). The former is far more performant, particularly when done a very large number of times like is the case here.

tekr commented 3 years ago

Will re-raise from a non-master branch on my fork in order to keep PRs for different issues separate.