Ejemplo n.º 1
0
  public void writeFile(String filePath, List<AggregateReport> aggregateReports) {
    BufferedWriter bufferedWriter = null;
    File file = new File(filePath);

    try {
      if (file.exists() == true) {
        bufferedWriter = new BufferedWriter(new FileWriter(file, true));
      } else {
        bufferedWriter = new BufferedWriter(new FileWriter(file));
      }
      String title = "并发数,平均响应时间(ms),error(%),QPS(/sec)";
      bufferedWriter.write(title + "\n");
      for (AggregateReport aggregateReport : aggregateReports) {
        // String result = aggregateReport.getThreads() + "," + aggregateReport.getLabel() + "," +
        // aggregateReport.getSamples() + "," + aggregateReport.getAverage() + "," +
        // aggregateReport.getMedian() + "," + aggregateReport.getNinetyLine() + "," +
        // aggregateReport.getMin() + "," + aggregateReport.getMax() + "," +
        // aggregateReport.getError() + "," + aggregateReport.getThroughput();
        String result =
            aggregateReport.getThreads()
                + ","
                + aggregateReport.getAverage()
                + ","
                + aggregateReport.getError()
                + ","
                + aggregateReport.getThroughput();
        bufferedWriter.write(result + "\n");
      }
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        if (bufferedWriter != null) bufferedWriter.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Ejemplo n.º 2
0
 /** @param args */
 public static void main(String[] args) {
   // TODO Auto-generated method stub
   FileTools fileTools = new FileTools();
   List<String> filePaths =
       fileTools.getAllFileDirectory(
           "/Users/gaochuanjun/Documents/12.新闻app性能测试/01.性能测试/02.20140523");
   for (String filePath : filePaths) {
     System.out.println(filePath);
   }
   List<AggregateReport> aggregateReports = fileTools.getContent(filePaths);
   for (AggregateReport aggregateReport : aggregateReports) {
     System.out.println(
         aggregateReport.getThreads()
             + ","
             + aggregateReport.getLabel()
             + ","
             + aggregateReport.getSamples()
             + ","
             + aggregateReport.getAverage()
             + ","
             + aggregateReport.getMedian()
             + ","
             + aggregateReport.getNinetyLine()
             + ","
             + aggregateReport.getMin()
             + ","
             + aggregateReport.getMax()
             + ","
             + aggregateReport.getError()
             + ","
             + aggregateReport.getThroughput());
   }
   fileTools.writeFile(
       "/Users/gaochuanjun/Documents/12.新闻app性能测试/01.性能测试/02.20140523/result.csv",
       aggregateReports);
 }