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. Fixes #14 #20

Closed tekr closed 3 years ago

tekr commented 3 years ago

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

MatchesHanderCostPostOptimisation

Note that this PR replaces a number of calls to string.BeginsWith() with string.Equals().

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

burakoner commented 3 years ago

I was on vacation, I can reply now. sorry for delay. Thank you for your contributions