You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2005/03/10 20:33:56 UTC
svn commit: r156983 - in xmlbeans/trunk:
src/store/org/apache/xmlbeans/impl/store/
test/perf/src/org/apache/xmlbeans/test/performance/v2/
Author: cezar
Date: Thu Mar 10 11:33:52 2005
New Revision: 156983
URL: http://svn.apache.org/viewcvs?view=rev&rev=156983
Log:
XmlCursor perf improvements.
Modified:
xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java
xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java
xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java
xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetAttributeV2.java
xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetElementV2.java
xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetAttributeV2.java
xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetElementV2.java
xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorWalkV2.java
Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cur.java Thu Mar 10 11:33:52 2005
@@ -140,7 +140,8 @@
int kind ( )
{
assert isPositioned();
- return _pos == 0 ? _xobj.kind() : _pos == END_POS ? -_xobj.kind() : TEXT;
+ int kind = _xobj.kind();
+ return _pos == 0 ? kind : (_pos == END_POS ? - kind : TEXT);
}
boolean isRoot ( ) { assert isPositioned(); return _pos == 0 && _xobj.kind() == ROOT; }
@@ -912,6 +913,31 @@
moveTo( parent );
return true;
+ }
+
+ void toRoot ()
+ {
+ Xobj xobj = _xobj;
+ while (!xobj.isRoot())
+ {
+ if (xobj._parent==null)
+ {
+ Cur r = _locale.tempCur();
+
+ r.createRoot();
+
+ Xobj root = r._xobj;
+
+ r.next();
+ moveNode( r );
+ r.release();
+
+ xobj = root;
+ break;
+ }
+ xobj = xobj._parent;
+ }
+ moveTo(xobj);
}
boolean hasText ( )
Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Cursor.java Thu Mar 10 11:33:52 2005
@@ -293,51 +293,75 @@
}
public boolean _isStartdoc() {
- return _currentTokenType().isStartdoc();
+ //return _currentTokenType().isStartdoc();
+ assert isValid();
+ return _cur.isRoot();
}
public boolean _isEnddoc() {
- return _currentTokenType().isEnddoc();
+ //return _currentTokenType().isEnddoc();
+ assert isValid();
+ return _cur.isEndRoot();
}
public boolean _isStart() {
- return _currentTokenType().isStart();
+ //return _currentTokenType().isStart();
+ assert isValid();
+ return _cur.isElem();
}
public boolean _isEnd() {
- return _currentTokenType().isEnd();
+ //return _currentTokenType().isEnd();
+ assert isValid();
+ return _cur.isEnd();
}
public boolean _isText() {
- return _currentTokenType().isText();
+ //return _currentTokenType().isText();
+ assert isValid();
+ return _cur.isText();
}
public boolean _isAttr() {
- return _currentTokenType().isAttr();
+ //return _currentTokenType().isAttr();
+ assert isValid();
+ return _cur.isNormalAttr();
}
public boolean _isNamespace() {
- return _currentTokenType().isNamespace();
+ //return _currentTokenType().isNamespace();
+ assert isValid();
+ return _cur.isXmlns();
}
public boolean _isComment() {
- return _currentTokenType().isComment();
+ //return _currentTokenType().isComment();
+ assert isValid();
+ return _cur.isComment();
}
public boolean _isProcinst() {
- return _currentTokenType().isProcinst();
+ //return _currentTokenType().isProcinst();
+ assert isValid();
+ return _cur.isProcinst();
}
public boolean _isContainer() {
- return _currentTokenType().isContainer();
+ //return _currentTokenType().isContainer();
+ assert isValid();
+ return _cur.isContainer();
}
public boolean _isFinish() {
- return _currentTokenType().isFinish();
+ //return _currentTokenType().isFinish();
+ assert isValid();
+ return _cur.isFinish();
}
public boolean _isAnyAttr() {
- return _currentTokenType().isAnyAttr();
+ //return _currentTokenType().isAnyAttr();
+ assert isValid();
+ return _cur.isAttr();
}
public TokenType _toNextToken() {
@@ -964,7 +988,8 @@
}
public boolean _hasNextToken() {
- return _cur.kind() != -ROOT;
+ //return _cur.kind() != -ROOT;
+ return _cur._pos!=Cur.END_POS || _cur._xobj.kind()!=ROOT;
}
public boolean _hasPrevToken() {
@@ -1254,8 +1279,9 @@
}
public void _toStartDoc() {
- while (_cur.toParent())
- ;
+// while (_cur.toParent())
+// ;
+ _cur.toRoot();
}
public void _toEndDoc() {
@@ -2882,217 +2908,217 @@
public boolean isStartdoc() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isStartdoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isStartdoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isEnddoc() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isEnddoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isEnddoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isStart() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isStart();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isStart();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isEnd() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isEnd();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isEnd();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isText() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isText();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isText();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isAttr() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isAttr();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isAttr();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isNamespace() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isNamespace();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isNamespace();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isComment() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isComment();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isComment();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isProcinst() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isProcinst();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isProcinst();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isContainer() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isContainer();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isContainer();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isFinish() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isFinish();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isFinish();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public boolean isAnyAttr() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isAnyAttr();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _isAnyAttr();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
@@ -3116,19 +3142,19 @@
public boolean hasNextToken() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _hasNextToken();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _hasNextToken();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
@@ -3314,19 +3340,19 @@
public boolean toFirstChild() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _toFirstChild();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _toFirstChild();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
@@ -3494,19 +3520,19 @@
public boolean toFirstAttribute() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _toFirstAttribute();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
return _toFirstAttribute();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
@@ -3728,37 +3754,37 @@
public void toStartDoc() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
_toStartDoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
_toStartDoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
public void toEndDoc() {
if (preCheck()) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
_toEndDoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
} else synchronized (_cur._locale) {
- _cur._locale.enter();
- try {
+// _cur._locale.enter();
+// try {
_toEndDoc();
- } finally {
- _cur._locale.exit();
- }
+// } finally {
+// _cur._locale.exit();
+// }
}
}
Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java Thu Mar 10 11:33:52 2005
@@ -1462,8 +1462,8 @@
assert available == getAvailable();
- if (available == 0)
- return 0;
+// if (available == 0)
+// return 0;
return available;
}
@@ -2541,7 +2541,7 @@
boolean hasChildren = false;
if (isContainer())
- {
+ { // is there a faster way to do this?
push();
next();
Modified: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetAttributeV2.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetAttributeV2.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetAttributeV2.java (original)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetAttributeV2.java Thu Mar 10 11:33:52 2005
@@ -68,8 +68,8 @@
// Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" ");
System.out.print("hash "+hash+" ");
- System.out.print("time "+cputime+"\n");
-
+ System.out.print("time "+cputime+" ");
+ System.out.print("time/it " + ((double)cputime)/((double)iterations) + "\n");
}
private int run(XmlCursor p_cursor) throws Exception
Modified: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetElementV2.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetElementV2.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetElementV2.java (original)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetElementV2.java Thu Mar 10 11:33:52 2005
@@ -68,8 +68,8 @@
// Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" ");
System.out.print("hash "+hash+" ");
- System.out.print("time "+cputime+"\n");
-
+ System.out.print("time "+cputime+" ");
+ System.out.print("time/it " + ((double)cputime)/((double)iterations) + "\n");
}
private int run(XmlCursor p_cursor) throws Exception
Modified: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetAttributeV2.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetAttributeV2.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetAttributeV2.java (original)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetAttributeV2.java Thu Mar 10 11:33:52 2005
@@ -81,8 +81,8 @@
// Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" sizetoset="+stringToSet.length()+" ");
System.out.print("hash "+hash+" ");
- System.out.print("time "+cputime+"\n");
-
+ System.out.print("time "+cputime+" ");
+ System.out.print("time/it " + ((double)cputime)/((double)iterations) + "\n");
}
private int run(XmlCursor p_cursor, String p_setval) throws Exception
Modified: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetElementV2.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetElementV2.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetElementV2.java (original)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorGetSetGetElementV2.java Thu Mar 10 11:33:52 2005
@@ -81,7 +81,8 @@
// Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" sizetoset="+stringToSet.length()+" ");
System.out.print("hash "+hash+" ");
- System.out.print("time "+cputime+"\n");
+ System.out.print("time "+cputime+" ");
+ System.out.print("time/it " + ((double)cputime)/((double)iterations) + "\n");
}
private int run(XmlCursor p_cursor, String p_setval) throws Exception
Modified: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorWalkV2.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorWalkV2.java?view=diff&r1=156982&r2=156983
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorWalkV2.java (original)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/v2/CursorWalkV2.java Thu Mar 10 11:33:52 2005
@@ -14,13 +14,13 @@
*/
package org.apache.xmlbeans.test.performance.v2;
-import java.io.CharArrayReader;
-
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.test.performance.utils.Constants;
import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import java.io.CharArrayReader;
+
public class CursorWalkV2
{
@@ -67,13 +67,14 @@
// Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" ");
System.out.print("hash "+hash+" ");
- System.out.print("time "+cputime+"\n");
+ System.out.print("time " + cputime+" ");
+ System.out.print("time/it " + ((double)cputime)/((double)iterations) + "\n");
}
private int run(XmlCursor cursor) throws Exception
{
int iHash = 0;
-
+
while(cursor.hasNextToken()){
// walk the doc with the cursor, computing the hash
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org