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!)
Profiling for performance.
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: 3408" data-attributes="member: 10402"><p>I also looked at the GUILocalizeStrings. Same idear same consequense. </p><p></p><p>The new code uses direct indexing instead of SelectSingleNode. This reduces the internal load of the method by 50% having. Now the only thing that takes time in the method is XmlDocument.Load. And since this is unavoidable....</p><p></p><p>New code</p><p>[code]</p><p> static bool LoadMap(string strFileName, ref System.Collections.Hashtable map, bool bDetermineNumberOfChars)</p><p> {</p><p> map.Clear();</p><p> try</p><p> {</p><p> XmlDocument doc = new XmlDocument();</p><p> doc.Load(strFileName);</p><p> if (doc.DocumentElement==null) return false;</p><p> string strRoot=doc.DocumentElement.Name;</p><p> if (strRoot!="strings") return false;</p><p> if (bDetermineNumberOfChars==true)</p><p> {</p><p> int iChars=255;</p><p> XmlNode nodeChars = doc.DocumentElement.SelectSingleNode("/strings/characters");</p><p> if (nodeChars!=null)</p><p> {</p><p> if (nodeChars.InnerText!=null && nodeChars.InnerText.Length>0)</p><p> {</p><p> try</p><p> {</p><p> iChars=Convert.ToInt32(nodeChars.InnerText);</p><p> if (iChars < 255) iChars=255;</p><p> }</p><p> catch(Exception)</p><p> {</p><p> iChars=255;</p><p> }</p><p> GUIGraphicsContext.CharsInCharacterSet=iChars;</p><p> }</p><p> }</p><p> }</p><p> XmlNodeList list=doc.DocumentElement.SelectNodes("/strings/string");</p><p></p><p> // new code start</p><p> // this loop is performed multitude of times and therefore converted to for instead of foreach</p><p> for (int x=0; x < list.Count; x++)</p><p> {</p><p> int iCode = (int)System.Int32.Parse(list[x].ChildNodes[0].InnerText);</p><p> string strLine = list[x].ChildNodes[1].InnerText;</p><p> map[iCode]=strLine;</p><p> }</p><p> return true;</p><p> // new code end</p><p></p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> Log.Write("exception loading language {0} err:{1} stack:{2}", strFileName, ex.Message,ex.StackTrace);</p><p> return false;</p><p> }</p><p> }</p><p>[/code]</p><p></p><p>And again ONLY load-times of MP, not overall performance.</p><p></p><p>Ojo</p></blockquote><p></p>
[QUOTE="ojo, post: 3408, member: 10402"] I also looked at the GUILocalizeStrings. Same idear same consequense. The new code uses direct indexing instead of SelectSingleNode. This reduces the internal load of the method by 50% having. Now the only thing that takes time in the method is XmlDocument.Load. And since this is unavoidable.... New code [code] static bool LoadMap(string strFileName, ref System.Collections.Hashtable map, bool bDetermineNumberOfChars) { map.Clear(); try { XmlDocument doc = new XmlDocument(); doc.Load(strFileName); if (doc.DocumentElement==null) return false; string strRoot=doc.DocumentElement.Name; if (strRoot!="strings") return false; if (bDetermineNumberOfChars==true) { int iChars=255; XmlNode nodeChars = doc.DocumentElement.SelectSingleNode("/strings/characters"); if (nodeChars!=null) { if (nodeChars.InnerText!=null && nodeChars.InnerText.Length>0) { try { iChars=Convert.ToInt32(nodeChars.InnerText); if (iChars < 255) iChars=255; } catch(Exception) { iChars=255; } GUIGraphicsContext.CharsInCharacterSet=iChars; } } } XmlNodeList list=doc.DocumentElement.SelectNodes("/strings/string"); // new code start // this loop is performed multitude of times and therefore converted to for instead of foreach for (int x=0; x < list.Count; x++) { int iCode = (int)System.Int32.Parse(list[x].ChildNodes[0].InnerText); string strLine = list[x].ChildNodes[1].InnerText; map[iCode]=strLine; } return true; // new code end } catch (Exception ex) { Log.Write("exception loading language {0} err:{1} stack:{2}", strFileName, ex.Message,ex.StackTrace); return false; } } [/code] And again ONLY load-times of MP, not overall performance. Ojo [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Profiling for performance.
Contact us
RSS
Top
Bottom