Project

General

Profile

« Previous | Next » 

Revision 705

Added by berkley almost 24 years ago

added timing info to main

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
77 77

  
78 78
          // Open a connection to the database
79 79
          MetaCatUtil   util = new MetaCatUtil();
80
          double startTime = System.currentTimeMillis();
80 81
          Connection dbconn = util.openDBConnection();
81

  
82
          double connTime = System.currentTimeMillis();
82 83
          // Execute the query
83 84
          DBQuery queryobj = new DBQuery(dbconn, util.getOption("saxparser"));
84 85
          FileReader xml = new FileReader(new File(xmlfile));
85 86
          Hashtable nodelist = null;
86 87
          nodelist = queryobj.findDocuments(xml, null, null);
87

  
88
          double stopTime = System.currentTimeMillis();
88 89
          // Print the reulting document listing
89 90
          StringBuffer result = new StringBuffer();
90 91
          String document = null;
91 92
          String docid = null;
92 93
          result.append("<?xml version=\"1.0\"?>\n");
93 94
          result.append("<resultset>\n"); 
94
  // following line removed by Dan Higgins to avoid insertion of query XML inside returned XML doc
95
  //        result.append("  <query>" + xmlfile + "</query>\n");
95
          // following line removed by Dan Higgins to avoid insertion of 
96
          // query XML inside returned XML doc
97
          //result.append("  <query>" + xmlfile + "</query>\n");
96 98
          Enumeration doclist = nodelist.keys(); 
97 99
          while (doclist.hasMoreElements()) {
98 100
            docid = (String)doclist.nextElement();
......
104 106

  
105 107
          System.out.println(result);
106 108

  
109
          double dbOpenTime = (connTime - startTime)/1000;
110
          double insertTime = (stopTime - connTime)/1000;
111
          double executionTime = (stopTime - startTime)/1000;
112
          System.out.println("\n\nTotal Execution time was: " + 
113
                             executionTime + " seconds.");
114
          System.out.println("Time to open DB connection was: " + dbOpenTime + 
115
                             " seconds.");
116
          System.out.println("Time to perform query was: " + insertTime +
117
                             " seconds.");
118
                    
107 119
        } catch (Exception e) {
108 120
          System.err.println("Error in DBQuery.main");
109 121
          System.err.println(e.getMessage());

Also available in: Unified diff