Package org.jboss.varia.stats

Examples of org.jboss.varia.stats.StatisticalItem


               buf.append("<table width='100%'>")
                  .append("<tr><th>item</th><th>%</th><th>avg</th><th>min</th><th>max</th></tr>");

               for(Iterator itemIter = itemMap.values().iterator(); itemIter.hasNext();)
               {
                  StatisticalItem item = (StatisticalItem) itemIter.next();
                  buf.append("<tr><td>")
                     .append(item.getValue())
                     .append("</td><td>")
                     .append(100*((double)item.getMergedItemsTotal() / report.getCount()))
                     .append("</td><td>")
                     .append(((double) item.getCount()) / report.getCount())
                     .append("</td><td>")
                     .append(item.getMinCountPerTx())
                     .append("</td><td>")
                     .append(item.getMaxCountPerTx())
                     .append("</td>");
               }

               buf.append("</table>");
            }
View Full Code Here


      Map itemMap = (Map) report.getStats().get(TxReport.SqlStats.NAME);
      if(itemMap != null)
      {
         for(Iterator items = itemMap.values().iterator(); items.hasNext();)
         {
            StatisticalItem item = (StatisticalItem) items.next();
            String sql = item.getValue().toLowerCase();

            SqlStats sqlStats = (SqlStats)sqls.get(sql);
            if(sqlStats == null)
            {
               sqlStats = new SqlStats(sql);
               sqls.put(sql, sqlStats);
            }
            sqlStats.total += item.getCount();

            if(sql.startsWith("select "))
            {
               int fromStart = sql.indexOf("from ");
               if(fromStart == -1)
               {
                  throw new IllegalStateException("FROM not found in: " + sql);
               }

               String table = sql.substring(fromStart + "from ".length());
               int tableEnd = table.indexOf(' ');
               if(tableEnd != -1)
               {
                  table = table.substring(0, tableEnd);
               }

               TableStats tableStats = (TableStats) tables.get(table);
               if(tableStats == null)
               {
                  tableStats = new TableStats(table);
                  tables.put(table, tableStats);
               }
               tableStats.selects += item.getCount();
            }
            else if(sql.startsWith("update "))
            {
               String table = sql.substring("update ".length());
               int tableEnd = table.indexOf(' ');
               if(tableEnd == -1)
               {
                  throw new IllegalStateException("Could not find end of the table name: " + sql);
               }

               table = table.substring(0, tableEnd);

               TableStats tableStats = (TableStats) tables.get(table);
               if(tableStats == null)
               {
                  tableStats = new TableStats(table);
                  tables.put(table, tableStats);
               }
               tableStats.updates += item.getCount();
            }
            else if(sql.startsWith("insert into "))
            {
               String table = sql.substring("insert into ".length());
               int tableEnd = table.indexOf('(');
               if(tableEnd == -1)
               {
                  throw new IllegalStateException("Could not find end of the table name: " + sql);
               }

               table = table.substring(0, tableEnd).trim();
               TableStats tableStats = (TableStats) tables.get(table);
               if(tableStats == null)
               {
                  tableStats = new TableStats(table);
                  tables.put(table, tableStats);
               }
               tableStats.inserts += item.getCount();
            }
            else if(sql.startsWith("delete from "))
            {
               String table = sql.substring("delete from ".length());
               int tableEnd = table.indexOf(' ');
               if(tableEnd == -1)
               {
                  throw new IllegalStateException("Could not find end of the table name: " + sql);
               }

               table = table.substring(0, tableEnd);
               TableStats tableStats = (TableStats) tables.get(table);
               if(tableStats == null)
               {
                  tableStats = new TableStats(table);
                  tables.put(table, tableStats);
               }
               tableStats.deletes += item.getCount();
            }
            else
            {
               throw new IllegalStateException("Unrecognized sql statement: " + sql);
            }
View Full Code Here

TOP

Related Classes of org.jboss.varia.stats.StatisticalItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.