2014-04-18 48 views
1

我正在使用Jmeter並希望確定每個用戶的每個請求的結束時間。如何知道Jmeter中每個用戶的每個請求的結束時間

請大家看看我的測試計劃:

線程組:2個用戶 循環:1個

2 HTTP請求(request_1,request_2)


開始測試Web性能,查看結果樹顯示:4個結果(2個表示request_1,2個表示request_2)

request_2:1已通過,1次失敗。看在結果樹的請求表,我看到:

Thread Name: [email protected] - Stepping Thread Group 1-1 
Sample Start: 2014-04-18 09:28:06 ICT 
Load time: 1100554 
Latency: 550450 
Size in bytes: 408190 
Headers size in bytes: 4774 
Body size in bytes: 403416 
Sample Count: 1 
Error Count: 0 
Response code: 200 
Response message: OK 

Response headers: 
HTTP/1.1 200 OK 
Date: Fri, 18 Apr 2014 02:28:15 GMT 
Server: Apache 
X-Powered-By: PHP/5.3.3 
Set-Cookie: ls23166422738597439695-runtime-publicportal=h4knpfldt76e3kvmunrn5i4u16; path=/limesurvey/ 
Expires: Mon, 26 Jul 1997 05:00:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate 
Pragma: no-cache 
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT" 
Last-Modified: Fri, 18 Apr 2014 02:36:09 GMT 
Cache-Control: post-check=0, pre-check=0 
Keep-Alive: timeout=15, max=100 
Connection: Keep-Alive 
Transfer-Encoding: chunked 
Content-Type: text/html; charset=utf-8 


HTTPSampleResult fields: 
ContentType: text/html; charset=utf-8 
DataEncoding: utf-8 

的問題是:

  1. 如何識別導致request_2是失敗的時候?以及如何顯示每個用戶的每個請求的結束時間?

  2. 如何在JMeter中的日誌面板中顯示信息(啓用GUI調試日誌模式),如「這是錯誤....因爲...」

  3. 此外,由於在日誌中面板(GUI中的活動日誌調試),某些時間日誌條目在線程1-n(n = 1,2 ...)處停止,30秒後,日誌繼續顯示。那麼,我想知道這個時候,Web服務器有錯誤,而在這個時候,Jmeter仍然發送請求或者等待Web服務器響應?

謝謝。

回答

2
  1. 它可以通過Beanshell Pre Processor做,你可以添加任何「有趣」 request.Example代碼孩子會是什麼樣子:

    import java.util.Date; 
    
        long end_time_ms = prev.getEndTime(); // obtain sampler end time (in milliseconds from 1st Jan 1970) 
        Date end_time_date = new Date(end_time_ms); //convert it to human-readable date if you prefer 
    
        String response_message = prev.getResponseMessage(); // get initial response message 
    
        StringBuilder response = new StringBuilder(); // initialize StringBuilder to construct new response 
        response.append(response_message); // add initial response message 
        response.append(System.getProperty("line.separator")); // add new line 
        response.append("Thread finished at: ").append(end_time_date); // add thread finish date 
        prev.setResponseMessage(response.toString()); // set new response message 
          log.info("Thread finished at:" + end_time_date"); // to print it to the log 
    
  2. 見上面BeanShell的代碼和圖片下面UI衝擊

Beanshell Post Processor Response Message Change Demo

從來沒有使用GUI除了開發或調試測試之外的任何東西。如果你想添加一些東西到日誌使用log.info("something");如上或JMeter __log()函數

相關問題