curcuru     02/03/26 05:20:51

  Modified:    test/java/src/org/apache/qetest ExecTestlet.java
  Log:
  Add simple perf element reporting for time the execution took;
  Note evaluating this measurement depends on many factors
  including isExternal and external JVM considerations
  
  Revision  Changes    Path
  1.2       +24 -3     
xml-xalan/test/java/src/org/apache/qetest/ExecTestlet.java
  
  Index: ExecTestlet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/ExecTestlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExecTestlet.java  11 Mar 2002 14:02:10 -0000      1.1
  +++ ExecTestlet.java  26 Mar 2002 13:20:51 -0000      1.2
  @@ -76,7 +76,7 @@
    * just construct a class and call main().
    *
    * @author [EMAIL PROTECTED]
  - * @version $Id: ExecTestlet.java,v 1.1 2002/03/11 14:02:10 curcuru Exp $
  + * @version $Id: ExecTestlet.java,v 1.2 2002/03/26 13:20:51 curcuru Exp $
    */
   public abstract class ExecTestlet extends FileTestlet
   {
  @@ -86,6 +86,12 @@
       public static final String OPT_PROGNAME = "progName";
   
       /**
  +     * Timing data: how long process takes to exec.  
  +     * Default is -1 to represent a bogus number.  
  +     */
  +    protected long timeExec = -1;
  +
  +    /**
        * Default path/name of external program to call, OR 
        * actual name of class to call.  
        * @return foo, must be overridden.
  @@ -181,7 +187,9 @@
               // ...and execute the method!
               Object[] mainArgs = new Object[1];
               mainArgs[0] = cmdline;
  +            final long startTime = System.currentTimeMillis();
               main.invoke(null, mainArgs);
  +            timeExec = System.currentTimeMillis() - startTime;
           }
           catch (Throwable t)
           {
  @@ -225,6 +233,7 @@
           //  to specify any additional environment needed for the 
           //  second arg to exec();
           String[] environment = null;
  +        final long startTime = System.currentTimeMillis();
           proc = r.exec(cmdline, environment);
   
           // Immediately begin capturing any output therefrom
  @@ -243,6 +252,8 @@
           {
               // Wait for the process to exit normally
               processReturnVal = proc.waitFor();
  +            // Record time we finally rejoin, i.e. when the process is done
  +            timeExec = System.currentTimeMillis() - startTime;
           }
           catch (InterruptedException ie1)
           {
  @@ -311,10 +322,20 @@
               buf.append("</system-out>\n");
           }
           logger.logElement(Logger.INFOMSG, "checkOutputStreams", attrs, 
buf.toString());
  -        attrs = null;
           buf = null;
  -        checkStreams(datalet, cmdline, outBuf, errBuf, processReturnVal);
   
  +        // Also log out a perf element by default
  +        attrs = new Hashtable();
  +        attrs.put("idref", datalet.getInput());
  +        attrs.put("program", cmdline[0]);
  +        attrs.put("isExternal", new Boolean(isExternal()));
  +        attrs.put("timeExec", new Long(timeExec));
  +        logger.logElement(Logger.STATUSMSG, "perf", attrs, 
"Performance/timing info");
  +        attrs = null;
  +
  +        // Also call worker method to allow subclasses to 
  +        //  override checking of the output streams, as available
  +        checkStreams(datalet, cmdline, outBuf, errBuf, processReturnVal);
       }
       /** 
        * Worker method to validate the System.out/.err streams.  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to