[Mono-bugs] [Bug 50678][Wis] New - XPath: We need to audit perf on Count and Position

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 13 May 2004 02:31:23 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by atsushi@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=50678

--- shadow/50678	2004-05-13 02:31:23.000000000 -0400
+++ shadow/50678.tmp.15489	2004-05-13 02:31:23.000000000 -0400
@@ -0,0 +1,53 @@
+Bug#: 50678
+Product: Mono: Class Libraries
+Version: unspecified
+OS: unknown
+OS Details: 
+Status: RESOLVED   
+Resolution: FIXED
+Severity: Unknown
+Priority: Wishlist
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: XPath: We need to audit perf on Count and Position
+
+With the new Reverse Axis queries, we can often override the Count method,
+which would save cloning the iterator and looping through it. We should
+also cache the Count value if we ever have to look it up in a forward axis.
+
+As well, we need to optimize queries such as:
+
+blah [last ()]
+
+So that they just do the following:
+XPathNavigator last = null;
+while (child_blah_iterator.MoveNext ())
+   last = child_blah_iterator.Current;
+
+return last;
+
+rather than:
+
+while (child_blah_iterator.MoveNext ()) {
+   XPathNodeIterator c = child_blah_iterator.Clone;
+   int count = pos;
+   while (c.MoveNext ()) {
+       count ++;
+   }
+   if (pos == count)
+       return child_blah_iterator.Current;
+}
+
+The first way runs in O(n) time, while the second runs in O(n^2) time.
+
+------- Additional Comments From atsushi@ximian.com  2004-05-13 02:31 -------
+Nowadays, as for reverse axes, results are stored in an array list
+(before calling the first MoveNext(), including that called by .Count)
+and Count just returns the array list's Count property.
+
+I don't think we need (or are possible to formalize) specific kind of
+queries, unless it is easily done && heavily used.