【正文】
如果大家都是做Web應用的性能測試,例如只有一個登錄的請求,那么在Aggregate Report中,會顯示一行數(shù)據(jù),共有10個字段,含義分別如下。 ,使用HHmmsAggregate Report是 JMeter 常用的一個 Listener,中文被翻譯為“聚合報告”。 ,使用ms為單位 START屬性也可以被拷貝給使用其他相同名字的變量。一些附加屬性通過JMeter定義。 函數(shù)被用來做什么 書寫函數(shù)字符串 函數(shù)助手對話框 函數(shù) 參數(shù)屬性描述是否需要jexl函數(shù)返回執(zhí)行Commons JEXL 表達式的結(jié)果。自定義函數(shù)允許one to replace only part of any given value, not just filling in blank values. With builtin functions users can pute new values at runtime based on previous response data, which thread the function is in, the time, and many other sources. These values are generated fresh for every request throughout the course of the test. 函數(shù)在線程之間是共享的。 This could be used to replace the DOMAIN field of all HTTP requests, for example making it a simple matter to change a test to target a different server with the same test. 這用不使用函數(shù)的替代是可能的,但是不方便而且intuitive。自定義靜態(tài)值允許當一個測試樹編譯并且提交運行時自定義變量被它們的靜態(tài)值代替。 time return current time in various formats split Split a string into variables logn log a message setProperty set a property read a property random number machineName get the local machine name intSum add variables counter 函數(shù)列表:圓括號周圍設(shè)置函數(shù)的參數(shù),例如${_time(YMD)}實際參數(shù)因函數(shù)而不同。當取樣日志文件被加載時如果需要數(shù)據(jù)將從文件從新得到19. 函數(shù)JMeter函數(shù)是一些能夠轉(zhuǎn)化在測試樹中取樣器或者其他配置元件的域的特殊值。這樣為每個取樣產(chǎn)生一個新的文件,并且保存文件為取樣器名。同樣圖片不會被包括。像上面展示的那樣,如果需要響應數(shù)據(jù)可以被保存為XML日志文件。取樣器屬性意義如下:屬性內(nèi)容t用時(ms)lt延時(ms)不是所有的取樣器支持這個ts時間標志s是否成功lb標簽rc響應代碼rm響應消息tn線程名dt數(shù)據(jù)類型de數(shù)據(jù)編碼by字節(jié)數(shù)ng在這個線程組中活躍的線程數(shù)na所有線程組中的活躍線程數(shù)rs,但是讀取它期望是rc。gt。lt。gt。lt。gt。lt。gt。lt。gt。lt。gt。lt。}.../responseData cookies class=/cookies method class=GET/method queryString class=/queryString url/url /Sample Sample t=200 lt=180 ts=1144371015641 s=true lb= rc=200 rm=OK tn=Listen 11 dt=bin de=ISO88591 by=5866 responseHeader class=HTTP/ 200 OKDate: Fri, 07 Apr 2006 00:50:14 GMT...ContentType: image/gif/responseHeader requestHeader class=MyHeader: MyValue/requestHeader responseData class=/responseData responseFile class=/responseFile cookies class=/cookies method class=GET/method queryString class=/queryString url/url /Sample responseHeader class=HTTP/ 200 OKDate: Fri, 07 Apr 2006 00:50:13 GMT...ContentType: text/html。 color: black。 } ... /binary /sampleResult/sampleResult.../testResults更新的XML()格式如下(轉(zhuǎn)行可以不相同):?xml version= encoding=UTF8?testResults version= HTTP Sample, with nested samples Sample t=1392 lt=351 ts=1144371014619 s=true lb=HTTP Request rc=200 rm=OK tn=Listen 11 dt=text de=iso88591 by=12407 Sample t=170 lt=170 ts=1144371015471 s=true lb= rc=200 rm=OK tn=Listen 11 dt=text de=ISO88591 by=1002 responseHeader class=HTTP/ 200 OKDate: Fri, 07 Apr 2006 00:50:14 GMT...ContentType: text/css/responseHeader requestHeader class=MyHeader: MyValue/requestHeader responseData class=body, td, th { fontsize: 95%。 color: black。列的表現(xiàn)順序是固定的,如下:*時間標志自從197011的毫秒數(shù)*用時毫秒*標簽取樣器標簽*響應代碼例如200、404*響應消息例如OK*線程名*數(shù)據(jù)類型*成功與否true或者false*失敗消息如果要的話*字節(jié)數(shù)在取樣中的字節(jié)數(shù)*URLXML文件格式如下:原始XML()格式如下(轉(zhuǎn)行可以不相同):?xml version= encoding=UTF8?testResults version=sampleResult timeStamp=1144365463297 dataType=text threadName=Listen 11 label=HTTP Request time=1502 responseMessage=OK responseCode=200 success=true sampleResult timeStamp=1144365464238 dataType=text threadName=Listen 11 label= time=171 responseMessage=OK responseCode=200 success=true property xml:space=preserve name=samplerData GET /property binary body, td, th { fontsize: 95%。CSV日志格式依賴于在配置中被選擇的數(shù)據(jù)項。為了最小的資源使用,刪除所有的監(jiān)聽器,并且使用l標志運行測試在非GUI模式來定義僅一個監(jiān)聽器。單擊edit Save As Image圖1Edit Save As Image 當在非GUI模式運行時,使用l標志為測試運行創(chuàng)建一個頂級監(jiān)聽器。相同的文件可以被多個取樣器使用但是確定它們都使用相同的配置!JMeter能夠保存任何監(jiān)聽器作為一個PNG文件。如果你僅期望記錄某幾個取樣,可以添加監(jiān)聽器作為取樣器的一個子節(jié)點。配置按鈕可以指定那些域被寫入文件,和是否把它作為一個CSV或者XML文件。為了圖形化觀察響應時間,可以添加圖形結(jié)果不同的監(jiān)聽器使用不同的方法顯示響應信息。結(jié)果可以顯示在樹、表格、圖表或者簡單的寫入一個日志文件。這是不是問題。每一可視化工具會使用它自己的風格去顯示結(jié)果。一旦JMeter完成你的測試計劃,從Run菜單選擇Stop。當所有測試停止,那個方塊變成灰色。從Run菜單,選擇Run。為了僅保存在測試計劃樹上的特殊分支,選擇在樹中用來啟動分支的測試計劃元件,然后右擊在菜單項中選擇Save。為了保存測試計劃,從File菜單選擇Save Test Plan(使用最新版本,它不再需要首先選擇測試計劃元件)。選擇Jakarta Users元件,添加一個Graph Resultsr監(jiān)聽器(Add Listener Graph Results)。t be able to keep up. Select the appropriate configuration for getting the message to publish. If you want the sampler to randomly select the message, place the messages in a directory and select the directory using browse.Select the message type. If the message is in object format, make sure the message is generated correctly.. JMS Publisher 你需要添加到你測試計劃的最后元件是一個監(jiān)聽器。例如,Orion JMS需要認證,然而ActiveMQ和MQSeries不需要ActiveMQ and MQSeries,the sampler will aggregate messages, since small messages will arrive very quickly. If the sampler didn39。t be able to keep up. 如果你需要讀取響應,選擇這個復選框There are two client implementations for subscribers. If the JMS provider exhibits zombie threads with one client, try the other. JMS Subscriber改變Name域為sample publisher,選擇這個復選框輸入InitialContextFactory的類名輸入提供者URL,輸入連接工廠名。例如,Orion JMS需要認證,然而ActiveMQ和MQSeries不需要ActiveMQ and MQSeries,the sampler will aggregate messages, since small messages will arrive very quickly. If the sampler didn39。然后,在樹中選擇JMS Subscriber元件,并且編輯下列屬性:改變Name域為sample subscriber,選擇這個復選框輸入InitialContextFactory的類名輸入提供者URL,輸入連接工廠名。如果沒有,關(guān)閉JMeter,拷貝jar文件過去,重啟JMeter。Reilly Users線程組。如果你修改元件名,這個樹會在你離開控制面板前自動使用新的文本更新這個樹(例如,當你選擇另一個樹元件時)。在大部分應用程序中,你必須在控制面板中手工改變。如果你輸入循環(huán)次數(shù)為0,那么JMeter將會運行你的測試一次。最后,清除標為Forever的復選框,并且在循環(huán)次數(shù)文本域中輸入2。所以,如果我們有5個用戶和一個5秒的RampUp Period,那么啟動用戶的延遲就是1秒(5用戶/5秒=1用戶每秒)。這個屬性告訴JMeter啟動每個用戶之間的時間間隔。在這個name文本域,輸入Subscribers。你現(xiàn)在可以在JMeter窗口右部分看到線程組控制面板()。下一步,你需要修改默認屬性。你現(xiàn)在可以在測試計劃下看到線程組元件。線程組告訴JMeter你想要模擬的用戶數(shù),用戶多久發(fā)送一次請求,它們發(fā)送多少請求。消息系統(tǒng)可以工作在同步和異步模式。消息系統(tǒng)和普通的HTTP請求有很大不同。在案例里它一般