Ejemplo n.º 1
0
 private void calculateTps(Payload payload, TransactionReport report) {
   try {
     if (payload != null && report != null) {
       boolean isCurrent = payload.getPeriod().isCurrent();
       String ip = payload.getIpAddress();
       Machine machine = report.getMachines().get(ip);
       if (machine == null) {
         return;
       }
       for (TransactionType transType : machine.getTypes().values()) {
         long totalCount = transType.getTotalCount();
         double tps = 0;
         if (isCurrent) {
           double seconds =
               (System.currentTimeMillis() - payload.getCurrentDate()) / (double) 1000;
           tps = totalCount / seconds;
         } else {
           double time =
               (report.getEndTime().getTime() - report.getStartTime().getTime()) / (double) 1000;
           tps = totalCount / (double) time;
         }
         transType.setTps(tps);
         for (TransactionName transName : transType.getNames().values()) {
           long totalNameCount = transName.getTotalCount();
           double nameTps = 0;
           if (isCurrent) {
             double seconds =
                 (System.currentTimeMillis() - payload.getCurrentDate()) / (double) 1000;
             nameTps = totalNameCount / seconds;
           } else {
             double time =
                 (report.getEndTime().getTime() - report.getStartTime().getTime()) / (double) 1000;
             nameTps = totalNameCount / (double) time;
           }
           transName.setTps(nameTps);
           transName.setTotalPercent((double) totalNameCount / totalCount);
         }
       }
     }
   } catch (Exception e) {
     Cat.logError(e);
   }
 }
Ejemplo n.º 2
0
  private void calculateTps(Payload payload, TransactionReport report) {
    try {
      if (payload != null && report != null) {
        boolean isCurrent = payload.getPeriod().isCurrent();
        double seconds;

        if (isCurrent) {
          seconds = (System.currentTimeMillis() - payload.getCurrentDate()) / (double) 1000;
        } else {
          Date endTime = report.getEndTime();
          Date startTime = report.getStartTime();

          if (endTime != null && startTime != null) {
            seconds = (endTime.getTime() - startTime.getTime()) / (double) 1000;
          } else {
            seconds = 60;
          }
        }
        new TpsStatistics(seconds).visitTransactionReport(report);
      }
    } catch (Exception e) {
      Cat.logError(e);
    }
  }