1 4 5 9 10 package org.openlaszlo.test.xmlrpc; 11 12 import java.util.*; 13 import java.io.*; 14 import javax.xml.rpc.*; 15 import javax.xml.parsers.*; 16 import javax.xml.namespace.*; 17 import org.w3c.dom.*; 18 import org.xml.sax.*; 19 import org.apache.axis.Constants; 20 import org.apache.axis.utils.*; 21 import org.apache.log4j.Logger; 22 23 class PerfDataParser 24 { 25 DocumentBuilder mBuilder; 26 27 public PerfDataParser() throws ParserConfigurationException 28 { 29 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 30 mBuilder = factory.newDocumentBuilder(); 31 } 32 33 34 public Map parse(String file) 35 throws IOException, SAXException { 36 37 Map map = new HashMap(); 38 39 Element root = mBuilder.parse(new InputSource(new FileReader(file))).getDocumentElement(); 40 NodeList children = root.getChildNodes(); 41 for (int i=0; i < children.getLength(); i++) { 42 Node node = children.item(i); 43 if (node.getNodeType() != Node.ELEMENT_NODE) continue; 44 Map item = new HashMap(); 45 NamedNodeMap attributes = ((Element)node).getAttributes(); 46 for (int j=0; j < attributes.getLength(); j++) { 47 Attr attr = (Attr)attributes.item(j); 48 item.put(attr.getName(), attr.getValue()); 49 } 50 map.put(item.get("id"), item); 51 } 52 53 return map; 54 } 55 } 56 57 58 public class PerfTest 59 { 60 static String PERF_DATA_DIR = "/home/pkang/perforce/qa/testharness/docroot/perf-data"; 61 62 static Map addrMap = new HashMap(); 63 64 static { 65 try { 66 PerfDataParser p = new PerfDataParser(); 67 addrMap.put(new Integer (0), p.parse(PERF_DATA_DIR + "/0k.xml")); 68 addrMap.put(new Integer (1), p.parse(PERF_DATA_DIR + "/1k.xml")); 69 addrMap.put(new Integer (10), p.parse(PERF_DATA_DIR + "/10k.xml")); 70 addrMap.put(new Integer (25), p.parse(PERF_DATA_DIR + "/25k.xml")); 71 } catch (Exception e) { 72 e.printStackTrace(); 73 } 74 } 75 76 public static Map getAddresses(int k) { 77 return (Map)addrMap.get(new Integer (k)); 78 } 79 } 80 | Popular Tags |