1 46 package org.jaxen.dom4j; 47 48 import java.net.URL ; 49 50 import org.dom4j.Document; 51 import org.dom4j.Element; 52 import org.dom4j.io.SAXReader; 53 54 class Performance { 55 56 public static void main(String [] args) { 57 try { 58 URL u = new URL ("http://www.ibiblio.org/xml/examples/shakespeare/much_ado.xml"); 59 Document doc = new SAXReader().read(u); 60 Dom4jXPath xpath = new Dom4jXPath("PLAY/ACT/SCENE/SPEECH/SPEAKER"); 61 62 long start = System.currentTimeMillis(); 63 64 int count = 0; 65 for (int i = 0; i < 1000; i++) { 66 Element speaker = (Element) xpath.selectSingleNode(doc); 67 count += (speaker == null ? 0 : 1); 68 } 69 70 long end = System.currentTimeMillis(); 71 System.out.println((end - start)); 72 System.out.println(count); 73 74 } catch (Exception ex) { 75 ex.printStackTrace(); 76 } 77 } 78 79 } 80 | Popular Tags |