home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Yet a couple of other performance suggestions
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="ojo" data-source="post: 3180" data-attributes="member: 10402"><p>I did some profiling using the newly released version of NProf (0.0.9) check <a href="http://nprof.sourceforge.net" target="_blank">http://nprof.sourceforge.net</a> (they seem to have some problems updating the sourceforge pages, so you will have to check this page for the newest download <a href="http://sourceforge.net/project/showfiles.php?group_id=74129" target="_blank">http://sourceforge.net/project/showfiles.php?group_id=74129</a>)</p><p></p><p>I found out that in the "main thread" 28% of the processing were done inside AMS.Profile.GetXmlDocument. 59 times the method was called and everytime the document was re-read, reparsed by the System.XML validator and populated into a XmlDocument object.</p><p></p><p>So i did some thinking. Why not read it once and just "cache" it. I realize this is not the final solution, since you will have to make even further changes to make sure the save method works correctly and maybe implement a FileWatcher to get it right. But it is "prove of concept" for the Singleton idear.</p><p></p><p>I made an new Class called SingletonXmlHolder. This class ensures that it only initializes once and reads the XML document once. Then I changed a bit in the GetXmlDocument() method and the result (drumrolls......) 0,15% of the processing time. </p><p></p><p>[code]</p><p>namespace AMS.Profile</p><p>{</p><p></p><p> class SingletonXmlHolder</p><p> {</p><p> private static SingletonXmlHolder instance;</p><p> private static System.Xml.XmlDocument _XmlDocument = new System.Xml.XmlDocument();</p><p></p><p> private SingletonXmlHolder()</p><p> {</p><p> } </p><p></p><p> public static SingletonXmlHolder GetInstance(string m_strFileName)</p><p> {</p><p> if(instance == null)</p><p> {</p><p> instance = new SingletonXmlHolder();</p><p> _XmlDocument.Load(m_strFileName);</p><p> }</p><p> return instance;</p><p> } </p><p></p><p> public System.Xml.XmlDocument XmlDocument</p><p> {</p><p> get { return _XmlDocument; }</p><p> }</p><p> } </p><p></p><p> public class Xml :IDisposable</p><p> {</p><p> // Fields</p><p> private string m_rootName = "profile";</p><p></p><p>.....</p><p></p><p> private XmlDocument GetXmlDocument()</p><p> {</p><p> // Check kept for the moment but should be moved to SingletonXmlHolder</p><p> if (!File.Exists(m_strFileName))</p><p> return null;</p><p></p><p> SingletonXmlHolder snglXmlHolder = SingletonXmlHolder.GetInstance(m_strFileName);</p><p> </p><p> return snglXmlHolder.XmlDocument;</p><p> }</p><p></p><p>.....</p><p>}</p><p></p><p>[/code]</p><p></p><p>What do you think ?</p><p></p><p>Ojo</p></blockquote><p></p>
[QUOTE="ojo, post: 3180, member: 10402"] I did some profiling using the newly released version of NProf (0.0.9) check [url]http://nprof.sourceforge.net[/url] (they seem to have some problems updating the sourceforge pages, so you will have to check this page for the newest download [url]http://sourceforge.net/project/showfiles.php?group_id=74129[/url]) I found out that in the "main thread" 28% of the processing were done inside AMS.Profile.GetXmlDocument. 59 times the method was called and everytime the document was re-read, reparsed by the System.XML validator and populated into a XmlDocument object. So i did some thinking. Why not read it once and just "cache" it. I realize this is not the final solution, since you will have to make even further changes to make sure the save method works correctly and maybe implement a FileWatcher to get it right. But it is "prove of concept" for the Singleton idear. I made an new Class called SingletonXmlHolder. This class ensures that it only initializes once and reads the XML document once. Then I changed a bit in the GetXmlDocument() method and the result (drumrolls......) 0,15% of the processing time. [code] namespace AMS.Profile { class SingletonXmlHolder { private static SingletonXmlHolder instance; private static System.Xml.XmlDocument _XmlDocument = new System.Xml.XmlDocument(); private SingletonXmlHolder() { } public static SingletonXmlHolder GetInstance(string m_strFileName) { if(instance == null) { instance = new SingletonXmlHolder(); _XmlDocument.Load(m_strFileName); } return instance; } public System.Xml.XmlDocument XmlDocument { get { return _XmlDocument; } } } public class Xml :IDisposable { // Fields private string m_rootName = "profile"; ..... private XmlDocument GetXmlDocument() { // Check kept for the moment but should be moved to SingletonXmlHolder if (!File.Exists(m_strFileName)) return null; SingletonXmlHolder snglXmlHolder = SingletonXmlHolder.GetInstance(m_strFileName); return snglXmlHolder.XmlDocument; } ..... } [/code] What do you think ? Ojo [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Yet a couple of other performance suggestions
Contact us
RSS
Top
Bottom