[jboss-cvs] JBossAS SVN: r107797 - in projects/jboss-jca/branches/performance: apps and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 25 23:18:50 EDT 2010


Author: jeff.zhang
Date: 2010-08-25 23:18:49 -0400 (Wed, 25 Aug 2010)
New Revision: 107797

Added:
   projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/HtmlBenchmarkReport.java
   projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/TxtBenchmarkReport.java
Modified:
   projects/jboss-jca/branches/performance/apps/build.xml
   projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/BenchmarkReport.java
   projects/jboss-jca/branches/performance/build.xml
Log:
[JBJCA-394] generate html report

Modified: projects/jboss-jca/branches/performance/apps/build.xml
===================================================================
--- projects/jboss-jca/branches/performance/apps/build.xml	2010-08-26 03:10:36 UTC (rev 107796)
+++ projects/jboss-jca/branches/performance/apps/build.xml	2010-08-26 03:18:49 UTC (rev 107797)
@@ -70,20 +70,35 @@
        Target: benchmark-report
        ================================= -->
   <target name="benchmark-report">
+<!--
     <copy todir="${build.dir}">
       <fileset dir="src/main/resources/" includes="*"/>
     </copy>
+-->
     <path id="benchmark.report.classpath">
       <fileset dir="${target.dir}" includes="ironjacamar-performance-apps.jar"/>
     </path>
+    <java classname="org.jboss.jca.performance.apps.HtmlBenchmarkReport" dir="${build.dir}">
+      <arg value="${root.dir}"/>
+      <arg value="${kit.version}"/>
+      <arg value="${report.num}"/>
+      <classpath refid="benchmark.report.classpath"/>
+    </java>
+  </target>
 
-    <java classname="org.jboss.jca.performance.apps.BenchmarkReport" dir="${build.dir}">
+  <!-- ================================= 
+       Target: benchmark-report-txt
+       ================================= -->
+  <target name="benchmark-report-txt">
+    <path id="benchmark.report.classpath">
+      <fileset dir="${target.dir}" includes="ironjacamar-performance-apps.jar"/>
+    </path>
+    <java classname="org.jboss.jca.performance.apps.TxtBenchmarkReport" dir="${build.dir}">
       <arg value="${root.dir}"/>
       <arg value="${kit.version}"/>
       <arg value="${report.num}"/>
       <classpath refid="benchmark.report.classpath"/>
     </java>
-
   </target>
 
   <!-- ================================= 

Modified: projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/BenchmarkReport.java
===================================================================
--- projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/BenchmarkReport.java	2010-08-26 03:10:36 UTC (rev 107796)
+++ projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/BenchmarkReport.java	2010-08-26 03:18:49 UTC (rev 107797)
@@ -22,196 +22,96 @@
 package org.jboss.jca.performance.apps;
 
 import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.List;
 
+
 /**
  * A BenchmarkReport.
  * 
  * @author Jeff Zhang
  * @version $Revision: $
  */
-public class BenchmarkReport
+public abstract class BenchmarkReport
 {
    /** workmanagerData */
-   private List<Data> workmanagerData = new ArrayList<Data>();
+   List<Data> workmanagerData = new ArrayList<Data>();
    /** workmanagerBlockData */
-   private List<Data> workmanagerBlockData = new ArrayList<Data>();
+   List<Data> workmanagerBlockData = new ArrayList<Data>();
    /** connectionData */
-   private List<Data> connectionData = new ArrayList<Data>();
+   List<Data> connectionData = new ArrayList<Data>();
    /** serverVersion */
    String serverVersion;
    
    /**
-    * main
-    *
-    * @param args param
+    * generateTextReport
+    * 
+    * @param fw writer
+    * @throws IOException
     */
-   public static void main(String[] args)
+   void generateTextReport(FileWriter fw) throws IOException
    {
-      if (args.length < 3)
-         usage("Wrong number of arguments.");
-      
+      writeTop(fw);
+      generateSubject(fw);
+      generateBody(fw);
+      writeBottom(fw);
 
-      String dataFilename = args[0] + File.separator + "runs" + File.separator + args[1] + File.separator + "raw"
-         + File.separator + args[2] + File.separator + "data.txt";
-      String reportDir = args[0] + File.separator + "reports" + File.separator + args[1] + File.separator + "benchmark"
-         + File.separator + args[2];
-      
-      try
-      {
-         FileInputStream fin = new FileInputStream(dataFilename);
-         InputStreamReader isr = new InputStreamReader(fin);
-         BufferedReader br = new BufferedReader(isr);
-
-         BenchmarkReport report = new BenchmarkReport();
-         report.serverVersion = args[1];
-         report.readData(br);
-         
-         File path = new File(reportDir);
-         if (!path.exists())
-         {
-            if (!path.mkdirs())
-               throw new IOException("outdir can't be created");
-         }
-         
-         FileWriter fw = new FileWriter(reportDir + File.separator + "report.txt");
-         report.generateTextReport(fw);
-         fin.close();
-         fw.close();
-      }
-      catch (IOException ioe)
-      {
-         ioe.printStackTrace();
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace();
-      }
    }
 
    /**
-    * generateTextReport
+    * write top header
     * 
     * @param fw writer
     * @throws IOException
     */
-   private void generateTextReport(FileWriter fw) throws IOException
-   {
-      String split[] = serverVersion.split("-");
-      if (split[0].equals("jbas"))
-         fw.write("JBoss Application Server ");
-      else if (split[0].equals("jbjca"))
-         fw.write("JBoss IronJacamar Server ");
-      
-      if (split[1].equals("daily"))
-         fw.write("SNAPSHOT");
-      else
-         fw.write(split[1]);
-      writeEol(fw);
-
-      if (workmanagerData.size() > 0)
-      {
-         fw.write("WorkManager test cases");
-         writeEol(fw);
-         writeEol(fw);
-         
-         writeHeader(fw);
-         writeData(fw, workmanagerData);
-      }
-      writeEol(fw);
-      if (workmanagerBlockData.size() > 0)
-      {
-         fw.write("WorkManager with block test cases");
-         writeEol(fw);
-         writeEol(fw);
-         
-         writeHeader(fw);
-         writeData(fw, workmanagerBlockData);
-      }
-      writeEol(fw);
-      if (connectionData.size() > 0)
-      {
-         fw.write("Connection test cases");
-         writeEol(fw);
-         writeEol(fw);
-         
-         writeHeader(fw);
-         writeData(fw, connectionData);
-      }
-   }
-
+   abstract void writeTop(FileWriter fw) throws IOException;
+   
    /**
-    * write data table header
+    * generate subject
     * 
     * @param fw writer
     * @throws IOException
     */
-   private void writeHeader(FileWriter fw) throws IOException
-   {
-      writeSperate(fw);
-      fw.write("Units");
-      writeSperate(fw);
-      fw.write("Time (ms)");
-      writeSperate(fw);
-      writeEol(fw);
-   }
-
+   abstract void generateSubject(FileWriter fw) throws IOException;
+   
    /**
-    * write end of line
+    * generate body
     * 
     * @param fw writer
     * @throws IOException
     */
-   private void writeEol(FileWriter fw) throws IOException
-   {
-      fw.write('\n');
-   }
+   abstract void generateBody(FileWriter fw) throws IOException;
    
    /**
-    * write sperate
+    * write bottom
     * 
     * @param fw writer
+    * @param data list of data
     * @throws IOException
     */
-   private void writeSperate(FileWriter fw) throws IOException
-   {
-      fw.write("\t\t");
-   }
+   abstract void writeBottom(FileWriter fw) throws IOException;
 
    /**
-    * write data
+    * write end of line
     * 
     * @param fw writer
-    * @param data list of data
     * @throws IOException
     */
-   private void writeData(FileWriter fw, List<Data> data) throws IOException
+   public void writeEol(FileWriter fw) throws IOException
    {
-      for (int i = data.size() - 1; i >= 0; i--)
-      {
-         Data item = data.get(i);
-         fw.write(item.getTrans());
-         writeSperate(fw);
-         fw.write(item.getNumber());
-         writeSperate(fw);
-         fw.write(item.getTime());
-         writeEol(fw);
-      }
+      fw.write('\n');
    }
-   
+
+  
    /**
     * read data from file
     * 
     * @param br reader
     * @throws IOException
     */
-   private void readData(BufferedReader br) throws IOException
+   void readData(BufferedReader br) throws IOException
    {
       String str;
       while ((str = br.readLine()) != null)

Added: projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/HtmlBenchmarkReport.java
===================================================================
--- projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/HtmlBenchmarkReport.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/HtmlBenchmarkReport.java	2010-08-26 03:18:49 UTC (rev 107797)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.performance.apps;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+/**
+ * A HtmlBenchmarkReport.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class HtmlBenchmarkReport extends BenchmarkReport
+{
+   
+   /**
+    * main
+    *
+    * @param args param
+    */
+   public static void main(String[] args)
+   {
+      if (args.length < 3)
+         usage("Wrong number of arguments.");
+      
+
+      String dataFilename = args[0] + File.separator + "runs" + File.separator + args[1] + File.separator + "raw"
+         + File.separator + args[2] + File.separator + "data.txt";
+      String reportDir = args[0] + File.separator + "reports" + File.separator + args[1] + File.separator + "benchmark"
+         + File.separator + args[2];
+      
+      try
+      {
+         FileInputStream fin = new FileInputStream(dataFilename);
+         InputStreamReader isr = new InputStreamReader(fin);
+         BufferedReader br = new BufferedReader(isr);
+
+         BenchmarkReport report = new HtmlBenchmarkReport();
+         report.serverVersion = args[1];
+         report.readData(br);
+         
+         File path = new File(reportDir);
+         if (!path.exists())
+         {
+            if (!path.mkdirs())
+               throw new IOException("outdir can't be created");
+         }
+         
+         FileWriter fw = new FileWriter(reportDir + File.separator + "report.html");
+         report.generateTextReport(fw);
+         fin.close();
+         fw.close();
+      }
+      catch (IOException ioe)
+      {
+         ioe.printStackTrace();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   /**
+    * write html header
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void writeTop(FileWriter fw) throws IOException
+   {
+      fw.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
+      writeEol(fw);
+      fw.write("<html><head><title>benchmark report</title></head><body>");
+      writeEol(fw);
+   }
+   
+   /**
+    * generate subject
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void generateSubject(FileWriter fw) throws IOException
+   {
+      fw.write("<p><b1>");
+      String split[] = serverVersion.split("-");
+      if (split[0].equals("jbas"))
+         fw.write("JBoss Application Server ");
+      else if (split[0].equals("jbjca"))
+         fw.write("JBoss IronJacamar Server ");
+      
+      if (split[1].equals("daily"))
+         fw.write("SNAPSHOT");
+      else
+         fw.write(split[1]);
+      fw.write("</b1></p>");
+      writeEol(fw);
+   }
+   /**
+    * generate body
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void generateBody(FileWriter fw) throws IOException
+   {
+      writeListData(fw, workmanagerData, "WorkManager test cases");
+      writeListData(fw, workmanagerBlockData, "WorkManager with block test cases");
+      writeListData(fw, connectionData, "Connection test cases");
+   }
+
+   /**
+    * write list data
+    * 
+    * @param fw
+    * @param data list of data
+    * @param text description
+    * @throws IOException
+    */
+   private void writeListData(FileWriter fw, List<Data> data, String text) throws IOException
+   {
+      if (data.size() > 0)
+      {
+         fw.write("<p><b2>");
+         fw.write(text);
+         fw.write("</b2></p>");
+         writeEol(fw);
+         fw.write("<table border=\"1\">");
+         writeEol(fw);
+         writeHeader(fw);
+         writeData(fw, data);
+         fw.write("</table>");
+         writeEol(fw);
+      }
+   }
+
+   
+   /**
+    * write data table header
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   void writeHeader(FileWriter fw) throws IOException
+   {
+      fw.write("<theader><td></td><td>Units</td><td>Time (ms)</td></theader>");
+      writeEol(fw);
+   }
+
+
+   /**
+    * write data
+    * 
+    * @param fw writer
+    * @param data list of data
+    * @throws IOException
+    */
+   void writeData(FileWriter fw, List<Data> data) throws IOException
+   {
+      for (int i = data.size() - 1; i >= 0; i--)
+      {
+         Data item = data.get(i);
+         fw.write("<tr><td>");
+         fw.write(item.getTrans());
+         fw.write("</td><td>");
+         fw.write(item.getNumber());
+         fw.write("</td><td>");
+         fw.write(item.getTime());
+         fw.write("</td></tr>");
+         writeEol(fw);
+      }
+   }
+   
+   /**
+    * write bottom
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void writeBottom(FileWriter fw) throws IOException
+   {
+      fw.write("</table></body></html>");
+      writeEol(fw);
+   }
+   
+
+   /**
+    * print usage
+    *
+    * @param msg usage message
+    */
+   static void usage(String msg)
+   {
+      System.err.println(msg);
+      System.err.println("Usage: java " + HtmlBenchmarkReport.class.getName() + " rootDir serverVersion runNumber");
+      System.exit(1);
+   }
+   
+}

Added: projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/TxtBenchmarkReport.java
===================================================================
--- projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/TxtBenchmarkReport.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/apps/src/main/java/org/jboss/jca/performance/apps/TxtBenchmarkReport.java	2010-08-26 03:18:49 UTC (rev 107797)
@@ -0,0 +1,222 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.performance.apps;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+/**
+ * A TxtBenchmarkReport.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class TxtBenchmarkReport extends BenchmarkReport
+{
+   
+   /**
+    * main
+    *
+    * @param args param
+    */
+   public static void main(String[] args)
+   {
+      if (args.length < 3)
+         usage("Wrong number of arguments.");
+      
+
+      String dataFilename = args[0] + File.separator + "runs" + File.separator + args[1] + File.separator + "raw"
+         + File.separator + args[2] + File.separator + "data.txt";
+      String reportDir = args[0] + File.separator + "reports" + File.separator + args[1] + File.separator + "benchmark"
+         + File.separator + args[2];
+      
+      try
+      {
+         FileInputStream fin = new FileInputStream(dataFilename);
+         InputStreamReader isr = new InputStreamReader(fin);
+         BufferedReader br = new BufferedReader(isr);
+
+         BenchmarkReport report = new TxtBenchmarkReport();
+         report.serverVersion = args[1];
+         report.readData(br);
+         
+         File path = new File(reportDir);
+         if (!path.exists())
+         {
+            if (!path.mkdirs())
+               throw new IOException("outdir can't be created");
+         }
+         
+         FileWriter fw = new FileWriter(reportDir + File.separator + "report.txt");
+         report.generateTextReport(fw);
+         fin.close();
+         fw.close();
+      }
+      catch (IOException ioe)
+      {
+         ioe.printStackTrace();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   /**
+    * write top
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void writeTop(FileWriter fw) throws IOException
+   {
+   }
+   
+   /**
+    * generate subject
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void generateSubject(FileWriter fw) throws IOException
+   {
+      String split[] = serverVersion.split("-");
+      if (split[0].equals("jbas"))
+         fw.write("JBoss Application Server ");
+      else if (split[0].equals("jbjca"))
+         fw.write("JBoss IronJacamar Server ");
+      
+      if (split[1].equals("daily"))
+         fw.write("SNAPSHOT");
+      else
+         fw.write(split[1]);
+      writeEol(fw);
+   }
+   
+   /**
+    * generate body
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void generateBody(FileWriter fw) throws IOException
+   {
+      if (workmanagerData.size() > 0)
+      {
+         fw.write("WorkManager test cases");
+         writeEol(fw);
+         writeEol(fw);
+         
+         writeHeader(fw);
+         writeData(fw, workmanagerData);
+      }
+      writeEol(fw);
+      if (workmanagerBlockData.size() > 0)
+      {
+         fw.write("WorkManager with block test cases");
+         writeEol(fw);
+         writeEol(fw);
+         
+         writeHeader(fw);
+         writeData(fw, workmanagerBlockData);
+      }
+      writeEol(fw);
+      if (connectionData.size() > 0)
+      {
+         fw.write("Connection test cases");
+         writeEol(fw);
+         writeEol(fw);
+         
+         writeHeader(fw);
+         writeData(fw, connectionData);
+      }
+   }
+
+   /**
+    * write data table header
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   private void writeHeader(FileWriter fw) throws IOException
+   {
+      writeSperate(fw);
+      fw.write("Units");
+      writeSperate(fw);
+      fw.write("Time (ms)");
+      writeSperate(fw);
+      writeEol(fw);
+   }
+   
+   /**
+    * write sperate
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   private void writeSperate(FileWriter fw) throws IOException
+   {
+      fw.write("\t\t");
+   }
+
+   /**
+    * write bottom
+    * 
+    * @param fw writer
+    * @throws IOException
+    */
+   @Override
+   void writeBottom(FileWriter fw) throws IOException
+   {
+   }
+   
+   /**
+    * write data
+    * 
+    * @param fw writer
+    * @param data list of data
+    * @throws IOException
+    */
+   private void writeData(FileWriter fw, List<Data> data) throws IOException
+   {
+      for (int i = data.size() - 1; i >= 0; i--)
+      {
+         Data item = data.get(i);
+         fw.write(item.getTrans());
+         writeSperate(fw);
+         fw.write(item.getNumber());
+         writeSperate(fw);
+         fw.write(item.getTime());
+         writeEol(fw);
+      }
+   }
+
+
+}

Modified: projects/jboss-jca/branches/performance/build.xml
===================================================================
--- projects/jboss-jca/branches/performance/build.xml	2010-08-26 03:10:36 UTC (rev 107796)
+++ projects/jboss-jca/branches/performance/build.xml	2010-08-26 03:18:49 UTC (rev 107797)
@@ -187,11 +187,18 @@
 
   <target name="benchmark-report" depends="jars">
     <ant dir="apps" inheritRefs="true" target="benchmark-report">
-      <property name="kit.version" value="jbjca-daily"/>
-      <property name="report.num" value="1"/>
+      <property name="kit.version" value="${kit.version}"/>
+      <property name="report.num" value="${report.num}"/>
     </ant>
   </target>
 
+  <target name="benchmark-report-txt" depends="jars">
+    <ant dir="apps" inheritRefs="true" target="benchmark-report-txt">
+      <property name="kit.version" value="${kit.version}"/>
+      <property name="report.num" value="${report.num}"/>
+    </ant>
+  </target>
+
   <!-- ================================= 
        Target: profiler
        ================================= -->



More information about the jboss-cvs-commits mailing list