2016-12-21 23 views
3

運行我的加載測試後,Jmeter生成結果到「summary.csv」。
在此文件中的某些網址的樣子:如何在jmeter加載運行後編輯summary.csv文件

1482255989405,3359,POST ...users/G0356GM7QOITIMGA/... 
1482255989479,3310,POST ...users/HRC50JG3T524N9RN/... 
1482255989488,3354,POST ...users/54QEGZB54BEWOCJJ/... 

其中 「...的用戶/ G0356GM7QOITIMGA/...」 - 它的網址列。
之後,我嘗試使用此命令生成JMeter的報告:

jmeter -g summary.csv -o report 

Howewer這個動作拋出內存異常(因爲許多不同的URL)。
所以我決定在拆解線程組編輯summary.csv和替換所有ID爲 「someID」 的字符串,用BeanShell的採樣

import java.io.*; 
import org.apache.jmeter.services.FileServer; 
try { 
     String sep = System.getProperty("line.separator"); 
     String summaryFileDirPath = FileServer.getFileServer().getBaseDir() + File.separator; 
     String summaryFilePath = summaryFileDirPath + "summary.csv"; 
     log.info("read " + summaryFilePath); 
     File file = new File(summaryFilePath); 
     BufferedReader reader = new BufferedReader(new FileReader(file)); 
     String line; 
     String text = ""; 
     while ((line = reader.readLine()) != null) { 
      text += line + sep; 
     } 
     reader.close(); 
     log.info(summaryFilePath); 
     file.delete(); 

     FileWriter writer = new FileWriter(summaryFileDirPath + "summary.csv", false); 
     writer.write(text.replaceAll("users/[A-Z0-9]*/", "users/EUCI/")); 
     writer.close(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

結果:
summary.csv screen

好像Jmeter追加了一些行tearDown線程組結束了他的工作。
如何在僅使用jmeter腳本測試運行後編輯summary.csv文件?
PS:我只需要在summary.csv收集結果

+0

提示的方式全面的信息:格式化事項。請花1分鐘時間來正確縮進您的源代碼。你希望我們花時間來幫助你......所以你請儘可能簡單直接地做出來。 – GhostCat

+0

感謝您的評論。我已經格式化了腳本。 –

回答

1

有一個JMeter的物業 - jmeter.save.saveservice.autoflush,則很可能是從false

# AutoFlush on each line written in XML or CSV output 
# Setting this to true will result in less test results data loss in case of Crash 
# but with impact on performances, particularly for intensive tests (low or no pauses) 
# Since JMeter 2.10, this is false by default 
#jmeter.save.saveservice.autoflush=false 

它的默認值患上您可以覆蓋在價值至少2種方式:

  1. 在下一行添加到user.properties文件:

    jmeter.save.saveservice.autoflush=true 
    
  2. 通過它傳遞給JMeter的-J命令行參數,如:

    jmeter -Jjmeter.save.saveservice.autoflush=true -n -t .... 
    

Apache JMeter Properties Customization Guide此文出於JMeter的性能,並與他們一起工作

+0

感謝您的回答。這幫助了我。我還有一個問題: - 如果可以禁用「BeanShell Sampler」登錄到summary.csv? [此問題的主題](http://stackoverflow.com/questions/41300570/how-can-i-disable-writing-beanshell-log-row-in-jmeter-report-summary-csv-file) –

相關問題