Forum Stats

  • 3,872,506 Users
  • 2,266,435 Discussions
  • 7,911,231 Comments

Discussions

esiira

843834
843834 Member Posts: 49,972
edited Jul 18, 2001 10:23AM in Java Technology & XML
I'd like to know if there is a way to measure the time it takes to parse and transform an XML document using the parser and processor contained in JAXP 1.1.

If anyone has tried this, I would be very thankful learning about the experience.

Thanks in advance

Erik

Comments

  • 843834
    843834 Member Posts: 49,972
    I don't know if there are a direct method in JAXP that measures the timing, but you could try to use the System.currentTimeMillis() to help you.

    Hope this helps,

    For example:
    double elapsedTime;
    long startTime = System.currentTimeMillis();
    
    // Read in the xml file and create a dom object
    Document doc;
    DocumentBuilder dbuilder;
    DocumentBuilderFactory dfactory;
    
    dfactory = DocumentBuilderFactory.newInstance();
    dbuilder = dfactory.newDocumentBuilder();
    doc = dbuilder.parse(new File(xmlFile));
    
    elapsedTime = (System.currentTimeMillis() -startTime)/1000.0;
    System.out.println("Parsing a document takes " + elapsedTime + " second(s).");
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  • 843834
    843834 Member Posts: 49,972
    Thanks a lot Wai Mna.

    This was exactly what I was looking for.

    It really helped me out.
This discussion has been closed.