Re: [Quickfix-developers] Fast message cloning, toString() setString()?
Brought to you by:
orenmnero
From: Dale W. <wi...@oc...> - 2010-10-04 19:59:48
|
Hi Wil, I know you asked about C#. Let me answer the question for C++ and see if that helps. By FAR the fastest way to clone a message in C++ is: FIX::Message newMessage(originalMessage); that is to use the copy constructor to initialize an auto variable. Note that there is no need to render the object into a string; no need for a data dictionary; and in C++ no need for heap allocation of the message object itself (allocation consists of bumping the stack pointer by sizeof(Message). Some of the contents may require heap allocation, but there's not a good, safe way around that. The equivalent code in C# FIX.Message newMessage = new FIX.Message(originalMessage); does require a heap allocation -- but then EVERYTHING in C# requires a heap allocation [yes, I know I'm exaggerating] so the .NET heap allocator/garbage collector is highly optimized to make this as painless as possible. Notice that in your technique of rendering the message to string then parsing the string into a new message you are using a heap allocated string! If I were writing the code and performance was critical, I'd go with the above technique then profile the code to see if more arcane techniques were indicated. If they were, I would be very sure to profile the results to be sure that any optimization I came up with didn't slow the system down too badly (grin) Dale On 10/4/2010 12:15 PM, Wilhelm Thomas wrote: > QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX Support: http://www.quickfixengine.org/services.html > > > > Hello, I'm using c# > I'm basically trying to clone super fast a message without having the > need to create a new Message everytime but just feeding the new string > via setString. > Unfortunatly string msg = message.Tostring() doesn't seem to output > the tag in the right order, so I can not do > another_message.setstring(@msg) > What is the fastest way to get the string out from a Message object so > I can feed an empty Message object? > Any other idea for a super fast cloning not involving the creation of > too many objects? > thanks for your help > Wil > > > ------------------------------------------------------------------------------ > Virtualization is moving to the mainstream and overtaking non-virtualized > environment for deploying applications. Does it make network security > easier or more difficult to achieve? Read this whitepaper to separate the > two and get a better understanding. > http://p.sf.net/sfu/hp-phase2-d2d > > > _______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers |