chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Barr <Philip.B...@synapps-solutions.com>
Subject FW: DotCMIS XmlElement Deserialisation Very Slow
Date Fri, 27 Sep 2013 16:45:48 GMT
Resent as a mail, don't know why I "posted" this...or if it makes any difference.

From: Philip Barr
Posted At: 27 September 2013 17:20
Posted To: Apache Chemistry
Conversation: DotCMIS XmlElement Deserialisation Very Slow
Subject: DotCMIS XmlElement Deserialisation Very Slow

Hi all,

The following method in converter.cs, line 112, currently creates  a new XmlSerialiser for
each invocation. This is very costly and when there are, for example, lots of Choice elements
in an aspect (which is how I noticed it, performance slipped to 16-17 seconds for an ISession.GetTypeDefinition()
call):

T DeserializeElement<T>(XmlElement element)

I think this should be changed to the following:
        private static readonly Dictionary<Type, XmlSerializer> xmlSerializerCache =
new Dictionary<Type, XmlSerializer>();

        /// <summary>
        /// Deserializes an elemenet.
        /// </summary>
        private static T DeserializeElement<T>(XmlElement element)
        {
            if (!xmlSerializerCache.ContainsKey(typeof(T)))
            {
                XmlRootAttribute xmlRoot = new XmlRootAttribute(element.LocalName);
                xmlRoot.Namespace = CMISNamespaceURI;
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(T), xmlRoot);
                xmlSerializerCache.Add(typeof(T), xmlSerializer);
            }

            T deserializeElement = (T)xmlSerializerCache[typeof(T)].Deserialize(new XmlNodeReader(element));

            return deserializeElement;
        }

Doing this sped things up significantly for me.

Cheers,
Phil.

Philip Barr | Head Of Development | SynApps Solutions Ltd<http://www.synapps-solutions.com/>.
mobile: +44 (0)7817556362 | skype: phil.barr
email: philip.barr@synapps-solutions.com<mailto:richard.wiffin@synapps-solutions.com>
[cid:image001.jpg@01CEBBA5.595629A0]<http://www.synapps-solutions.com/>
[cid:image002.png@01CEBBA5.595629A0]<https://twitter.com/SynAppsSol>[cid:image003.png@01CEBBA5.595629A0]<http://www.linkedin.com/company/synapps-solutions-ltd>


IMPORTANT NOTICE

This e-mail contains information which is confidential and may be privileged and is for the
exclusive use of the recipient. If you are not the named recipient please contact the sender
immediately and delete the communication from your system. You are hereby notified that any
disclosure, distribution or copying of this communication, in whole or in part, is strictly
prohibited. It is the responsibility of the recipient to ensure that this message and its
attachments are virus free. Any views or opinions presented are solely those of the author
and do not necessarily represent those of the Company, its directors or officers unless otherwise
specifically stated. The Company is not responsible for any reliance placed on the information
contained herein and excludes all liability.

SynApps Solutions Limited is a company registered in England & Wales. Company Registration
No.: 047702224. VAT No.: 823778892

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message