What's the most efficient way to parse FIX Protocol messages in .NET?

前端 未结 4 1953
梦谈多话
梦谈多话 2021-02-01 10:34

I came across this very similar question but that question is tagged QuickFIX (which is not relevant to my question) and most of the answers are QuickFIX-related.

My que

4条回答
  •  攒了一身酷
    2021-02-01 11:14

    I would definitely start implementing your first approach, because it sounds clear and easy to do.

    A Dictionary seems very good to me, maybe wrapped up in a FixMessage class exposing methods like GetFieldHavingTag(int tag) etc...

    I don't know the FIX protocol, but looking at you example seems that messages are usually short and the fields as well, so memory allocation pressure shouldn't be a problem.

    Of course, the only way to be sure if an approach is good or not for you, is to implement it and test it.

    If you notice that the method is slow in case of a lot of messages, then profile it and find what/where is the problem.

    If you can't solve it easily, then yes, change strategy, but I'd like to enforce the idea that you need to test it first, then profile it and eventually change it.

    So, let's imagine that after your first implementation you've noticed that a lot of strings allocation are slowing down your performaces in case of many messages.

    Then yes, I would take an approach similar to your 3rd one, let's call it "on demand/lazy approach".

    I'd build a class FixMessage taking the string message and doing nothing until any message-field is needed.
    In that case I would use IndexOf (or something similar) to search the requested field/s, perhaps caching results to be faster in case of another equal request.

提交回复
热议问题