1 2 6 package com.hp.hpl.jena.rdf.arp.test; 7 import java.io.*; 8 9 import com.hp.hpl.jena.rdf.arp.*; 10 import org.xml.sax.ErrorHandler ; 11 import org.xml.sax.SAXParseException ; 12 13 class Performance { 14 static String allFiles[][] = 15 { 16 { 17 "testing/arp/onts/ont1", 18 "http://cicho0.tripod.com/cs_Courses_ont" }, 19 { 20 "testing/arp/onts/ont2", 21 "http://cicho0.tripod.com/cs_LecturingStaff_ont" }, 22 { 23 "testing/arp/onts/ont3", 24 "http://cicho0.tripod.com/cs_Staff_ont" }, 25 { 26 "testing/arp/onts/ont4", 27 "http://cicho0.tripod.com/Dep_of_Computer_Science" }, 28 { 29 "testing/arp/onts/ont10", 30 "http://daml.umbc.edu/ontologies/calendar-ont.daml" }, 31 { 32 "testing/arp/onts/ont11", 33 "http://daml.umbc.edu/ontologies/classification.daml" }, 34 { 35 "testing/arp/onts/ont12", 36 "http://daml.umbc.edu/ontologies/dreggie-ont.daml" }, 37 { 38 "testing/arp/onts/ont13", 39 "http://daml.umbc.edu/ontologies/profile-ont.daml" }, 40 { 41 "testing/arp/onts/ont14", 42 "http://daml.umbc.edu/ontologies/talk-ont.daml" }, 43 { 44 "testing/arp/onts/ont15", 45 "http://daml.umbc.edu/ontologies/topic-ont.daml" }, 46 { 47 "testing/arp/onts/ont16", 48 "http://daml.umbc.edu/ontologies/trust-ont.daml" }, 49 { 50 "testing/arp/onts/ont17", 51 "http://derpi.tuwien.ac.at/~andrei/cerif-rdf-dc-mn.daml" }, 52 { 53 "testing/arp/onts/ont18", 54 "http://edge.mcs.drexel.edu/MUG/2001/05/16/sbf.daml" }, 55 { 56 "testing/arp/onts/ont19", 57 "http://grcinet.grci.com/maria/www/codipsite/Onto/DublinCore/DublinCore_V27Aug2001.daml" }, 58 { 59 "testing/arp/onts/ont20", 60 "http://grcinet.grci.com/maria/www/codipsite/Onto/Project/ProjectOntology_V26Jul2001.daml" }, 61 { 62 "testing/arp/onts/ont21", 63 "http://grcinet.grci.com/maria/www/codipsite/Onto/TMD/TMDOntology_V27Aug2001.daml" }, 64 { 65 "testing/arp/onts/ont22", 66 "http://grcinet.grci.com/maria/www/codipsite/Onto/WebDirectory/WebDirectory_V27Aug2001.daml" }, 67 { 68 "testing/arp/onts/ont23", 69 "http://grcinet.grci.com/maria/www/CodipSite/Onto/WebSite/WebSiteOntology_V27Aug2001.daml" }, 70 { 71 "testing/arp/onts/ont26", 72 "http://isx.com/~phaglic/horus/daml/onts/englishpubont.daml" }, 73 { 74 "testing/arp/onts/ont27", 75 "http://ksl.stanford.edu/projects/DAML/chimaera-jtp-cardinality-test1.daml" }, 76 { 77 "testing/arp/onts/ont28", 78 "http://mnemosyne.umd.edu/~aelkiss/daml/serial1.2.daml" }, 79 84 { 85 "testing/arp/onts/ont29", 86 "http://mnemosyne.umd.edu/~aelkiss/weather-ont.daml" }, 87 { 88 "testing/arp/onts/ont30", 89 "http://mr.teknowledge.com/DAML/ArtOntology.daml" }, 90 { 91 "testing/arp/onts/ont31", 92 "http://mr.teknowledge.com/daml/Homeworks/HomeWork1/ResearchProjectOntology.daml" }, 93 { 94 "testing/arp/onts/ont32", 95 "http://mr.teknowledge.com/daml/homeworks/HomeWork3/BriefingOntology.daml" }, 96 { 97 "testing/arp/onts/ont34", 98 "http://mr.teknowledge.com/DAML/Imaging.daml" }, 99 { 100 "testing/arp/onts/ont35", 101 "http://mr.teknowledge.com/daml/ontologies/ImageFingerprinting/2001/04/BriefingsOntology.daml" }, 102 { 103 "testing/arp/onts/ont36", 104 "http://mr.teknowledge.com/daml/ontologies/ImageFingerprinting/2001/04/ImageFingerprintingOntology-web.daml" }, 105 { 106 "testing/arp/onts/ont37", 107 "http://mr.teknowledge.com/daml/ontologies/ImageFingerprinting/2001/04/ImageFingerprintsOntology-briefings.daml" }, 108 { 109 "testing/arp/onts/ont38", 110 "http://mr.teknowledge.com/DAML/pptOntology.daml" }, 111 { 112 "testing/arp/onts/ont39", 113 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_I1.daml" }, 114 { 115 "testing/arp/onts/ont40", 116 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_I2.daml" }, 117 { 118 "testing/arp/onts/ont41", 119 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_I3.daml" }, 120 { 121 "testing/arp/onts/ont42", 122 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_I4.daml" }, 123 { 124 "testing/arp/onts/ont43", 125 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_II1.daml" }, 126 { 127 "testing/arp/onts/ont44", 128 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_II2.daml" }, 129 { 130 "testing/arp/onts/ont45", 131 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_II3.daml" }, 132 { 133 "testing/arp/onts/ont46", 134 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_II4.daml" }, 135 { 136 "testing/arp/onts/ont47", 137 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_III1.daml" }, 138 { 139 "testing/arp/onts/ont48", 140 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_III2.daml" }, 141 { 142 "testing/arp/onts/ont49", 143 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_III3.daml" }, 144 { 145 "testing/arp/onts/ont50", 146 "http://ontobroker.semanticweb.org/ontos/compontos/tourism_III4.daml" }, 147 { 148 "testing/arp/onts/ont53", 149 "http://opencyc.sourceforge.net/daml/cyc-transportation.daml" }, 150 { 151 "testing/arp/onts/ont54", 152 "http://opencyc.sourceforge.net/daml/cyc.daml" }, 153 { 154 "testing/arp/onts/ont55", 155 "http://opencyc.sourceforge.net/daml/naics" }, 156 { 157 "testing/arp/onts/ont56", 158 "http://orlando.drc.com/daml/ontology/Bibliographic/current/" }, 159 { 160 "testing/arp/onts/ont57", 161 "http://orlando.drc.com/daml/Ontology/Commercial/Shipping/current/" }, 162 { 163 "testing/arp/onts/ont58", 164 "http://orlando.drc.com/daml/Ontology/Condition/UJTL/v4.0/current/" }, 165 { 166 "testing/arp/onts/ont59", 167 "http://orlando.drc.com/daml/Ontology/DAML-extension/current/" }, 168 { 169 "testing/arp/onts/ont60", 170 "http://orlando.drc.com/daml/ontology/DC/current/" }, 171 { 172 "testing/arp/onts/ont61", 173 "http://orlando.drc.com/daml/ontology/Fugitive/current/" }, 174 { 175 "testing/arp/onts/ont62", 176 "http://orlando.drc.com/daml/Ontology/Genealogy/current/" }, 177 { 178 "testing/arp/onts/ont63", 179 "http://orlando.drc.com/daml/ontology/Glossary/current/" }, 180 { 181 "testing/arp/onts/ont64", 182 "http://orlando.drc.com/daml/Ontology/GPS/Coordinates/current/" }, 183 { 184 "testing/arp/onts/ont65", 185 "http://orlando.drc.com/daml/Ontology/Intelligence/Report/current/" }, 186 { 187 "testing/arp/onts/ont66", 188 "http://orlando.drc.com/daml/ontology/Locator/current/" }, 189 { 190 "testing/arp/onts/ont67", 191 "http://orlando.drc.com/daml/ontology/Organization/current/" }, 192 { 193 "testing/arp/onts/ont68", 194 "http://orlando.drc.com/daml/ontology/Person/current/" }, 195 { 196 "testing/arp/onts/ont69", 197 "http://orlando.drc.com/daml/Ontology/POC/current/" }, 198 { 199 "testing/arp/onts/ont70", 200 "http://orlando.drc.com/daml/ontology/TaskList/current/" }, 201 545 }; 546 static String files[][]; 547 static int totalLength; 548 static int totalTime; 549 static public void main(String args[]) { 550 int k; 551 files = new String [20][]; 552 for (int ii = 0; 553 ii + files.length <= allFiles.length; 554 ii += files.length) { 555 for (k = 0; k < files.length; k++) 556 files[k] = allFiles[ii+k]; 557 totalLength = 0; 558 double s1 = speed(); 559 double s2 = speed(); 560 System.err.println( 561 files[0][0] 562 + "\t" 563 + totalLength 564 + "\t" 565 + s1 +"\t" + s2 566 + "\t" 567 + files[0][1]); 568 569 } 570 System.err.println("Total time: " + totalTime + " ms"); 571 } 572 static byte[][] load() { 573 byte rslt[][] = new byte[files.length][]; 574 for (int i = 0; i < files.length; i++) { 575 File f = new File(files[i][0]); 576 totalLength += (int) f.length(); 577 if (f.length() == 0) 578 continue; 579 rslt[i] = new byte[(int) f.length()]; 580 try { 581 InputStream in = new FileInputStream(f); 582 in.read(rslt[i]); 583 in.close(); 584 } catch (IOException e) { 585 System.err.println(files[i][1] + " " + e.getMessage()); 586 } 587 } 588 return rslt; 589 } 590 static int sum(byte array[]) { 591 int r = 0; 592 if (array == null) 593 return 0; 594 for (int i = 0; i < array.length; i++) 595 r += array[i]; 596 return r; 597 } 598 static double speed() { 599 boolean realData = false; 600 byte data[][] = load(); 601 int s = 0; 602 long startRead = System.currentTimeMillis(); 603 for (int i = 0; i < files.length; i++) 604 for (int k = 0; k < 50; k++) 605 s += sum(data[i]); 606 long startTest = System.currentTimeMillis(); 607 for (int i = 0; i < files.length; i++) 608 try { 609 if (data[i] == null) 610 continue; 611 realData = true; 612 parseRDF(new ByteArrayInputStream(data[i]), files[i][1]); 613 } catch (IOException e) { 614 System.err.println("byteArray " + e.getMessage()); 615 } 616 long endTime = System.currentTimeMillis(); 617 totalTime += (int)(endTime-startTest); 618 if (!realData) 619 return Double.NaN; 620 return (double) (endTime - startTest) 621 / (double) (startTest - startRead); 622 } 623 static void parseRDF(InputStream in, String base) throws IOException { 624 ErrorHandler eh = new ErrorHandler () { 625 public void warning(SAXParseException e) { 626 } 627 public void error(SAXParseException e) { 628 } 629 public void fatalError(SAXParseException e) { 630 } 631 }; 632 InputStream oldIn = System.in; 633 InputStream ntIn = null; 634 try { 635 System.setIn(in); 636 NTriple.mainEh( 637 new String [] { "-b", base, "-t" }, 638 eh, null); 639 640 } catch (Exception e) { 641 System.err.println(base + " " + e.toString()); 642 } finally { 643 System.setIn(oldIn); 644 if (ntIn != null) 645 ntIn.close(); 646 } 647 } 648 649 } 650 | Popular Tags |