コード例 #1
0
 private void printDatabasePerfElement(
     String elementName, HCPerfElement element, AvgMetric avg, boolean printAll) {
   if (printAll) {
     String kbSec = element.getKbSec();
     String runKBSec = null;
     if (kbSec != null) runKBSec = Double.toString(avg.getRunAvgKBTransferred());
     System.out.println(
         allStatsFormatter.sprintf(
             new String[] {
               new StringBuffer(elementName).append(":").toString(),
               getDoubleValue(element.getOpSec()),
               PrecisionFormatter.formatValue(avg.getAvgResponseTime(), 2),
               getDoubleValue(kbSec),
               PrecisionFormatter.formatValue(avg.getRunAvgOpPerSec(), 2),
               PrecisionFormatter.formatValue(avg.getRunAvgResponseTime(), 2),
               getDoubleValue(runKBSec)
             }));
   } else {
     System.out.println(
         statsFormatter.sprintf(
             new String[] {
               new StringBuffer(elementName).append(":").toString(),
               getLongValue(element.getOps()),
               getDoubleValue(element.getOpSec()),
               getDoubleValue(element.getKbSec()),
             }));
   }
 }
コード例 #2
0
  /**
   * Add <code>valueToAdd</code> metrics to the <code>avg</code> metrics object for the metric
   * <code>metric</code>
   *
   * @param metric the metric type being added
   * @param avg the average metric object that is being added to
   * @param valueToAdd the values being added to <code>avg</code> object
   */
  private void addToAvg(String metric, AvgMetric avg, HCPerfElement valueToAdd) {
    if (valueToAdd == null) return;

    BigInteger execTime = valueToAdd.getExecTime();
    BigInteger ops = valueToAdd.getOps();
    String opsPerSec = valueToAdd.getOpSec();
    if (execTime == null || ops == null || opsPerSec == null) {
      // These should never be null
      Logger.getLogger(CommandPerfStats.class.getName())
          .log(
              Level.WARNING,
              "CLI Internal Error: "
                  + metric
                  + " got unexpected null value, execTime="
                  + execTime
                  + " ops="
                  + ops);
      return;
    }

    // The underlying code on the server always does it calculations
    // using the time interval we specified.  We need the actual time
    // interval to get really accurate calculations here.  However,
    // since the design of performance needs to change (in where
    // the client should do the calculations) for now keep it simple and
    // just use the time interval we set since we know this is what
    // the master is doing for us.  This won't be accurate if 2+ users
    // are doing performance monitoring.
    String kbPerSec = valueToAdd.getKbSec();
    if (kbPerSec == null) avg.add(ops.longValue(), pollingInterval, execTime.longValue());
    else avg.add(ops.longValue(), pollingInterval, execTime.longValue(), Double.valueOf(kbPerSec));
  }