Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] XOMTestCase.assertEquals() too slow

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <wolfgang.hoschek AT mac.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] XOMTestCase.assertEquals() too slow
  • Date: Thu, 25 Jan 2007 20:24:48 -0800

I have a test driver that runs tens of thousands of XML files from a test suite through XOMTestCase.assertEquals(Document, Document), among other functions. It works correctly, but takes hours to complete, so I thought I'd take a quick peek. For example, it turns out that, when running the simple non-namespaced 8 MB document downloadable at http://dsd.lbl.gov/~hoschek/tmp/largeemp.xml.tar.gz through the example code below, it takes only a split second to parse the document, but about 2 minutes to complete assertEquals(). While I'm normally more worried about the clarity than the performance of test case code, things are clearly getting a bit out of hands here. It's not clear why XOMTestCase.assertEquals() should be orders of magnitude slower than parsing or serialization. All of these should clearly be O(N) overall. Any significant improvement would be appreciated. The tests don't have to be blazing fast, just bearable.

import java.io.File;

import nu.xom.Builder;
import nu.xom.Document;
import nu.xom.tests.XOMTestCase;

public class AssertEqualsTest {

public static void main(String[] args) throws Exception {
long duration = 0;
Builder builder = new Builder();

for (int i=0; i < args.length; i++) {
Document doc1 = builder.build(new File(args[i]));
Document doc2 = new Document(doc1);
System.out.print(".");
long start = System.currentTimeMillis();

XOMTestCase.assertEquals(doc1, doc2);

long end = System.currentTimeMillis();
duration = duration + (end - start);
}

System.out.println("secs = " + (duration / 1000.0f));
}

}





Archive powered by MHonArc 2.6.24.

Top of Page