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