使用性能測試工具Grinder做性能測試

<!-- /* Font Definitions */ @font-face {font-family:宋體; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋體"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋體; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋體; mso-bidi-font-family:宋體;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

核桃博客 轉載,http://www.hetaoblog.com/?p=63

使用性能測試工具Grinder做性能測試

 

使用性能測試工具Grinder來測試Java API的性能1

之前在使用性能測試工具JMeter來測試網站性能1 介 紹了使用JMeter來測試網站性能,JMeter可以對有登陸驗證的web項目進行測試,並且做一定的邏輯控制,多種輸出方式和較爲靈活的線程設置等。 雖然JMeter可以有一定的邏輯控制等方式,建立較複雜的測試邏輯;打開保存好的JMeter測試計劃文件(.jmx)文件可以看到,本質 上,JMeter生成的腳本是xml格式的,通過xml來描述測試邏輯自然比較累贅,這裏介紹另外一款測試工具, Grinder,通過Jython腳本的方式來描述測試邏輯,可以獲得Python腳本的方便性和對Java API的完整支持;

Grinder也是sourceforge旗下的一個開源項目,地址是http://grinder.sourceforge.net ,當前版本是3.3. Grinder的整體架構如下:

使用說明,

  1. 將下載到本地後,解壓,將“lib/grinder.jar”放到classpath,
  2. 到examples目錄下,命令行下輸入java net.grinder.Console,啓動Console界面如下

  1. 到examples目錄下,命令行下輸入java net.grinder.Grinder,啓動一個agent進程,如果看到如下信息,就說明Agent啓動成功了:

10-1-4 21:19:52 (agent): The Grinder 3.3

10-1-4 21:19:52 (agent): connected to console at localhost/127.0.0.1:6372

10-1-4 21:19:52 (agent): waiting for console signal

  1. 點擊Console界面上工具欄上第一個圖標”啓動worker進程“,然後點擊結果tab,就可以看到類似下圖的數據結果

說明:

1. grinder.properties配置

Grinder使用當前目錄下的grinder.properties配置文件指定性能測試的相關設置,所有配置在example目錄下有一個默認 文件,所有字段也都有一個默認值(比如grinder.threads,grinder.processes等),可以手動修改;

2. 使用的腳本

在example目錄下的grinder.properties裏面,腳本是如下指定的,

grinder.script = helloworld.py

也就是說,運行的是helloworld.py腳本,其內容是打印一句helloworld,可以在log目錄目錄下的 out_machine_name.log下看到輸出,可以自己修改配置指定sample下的其他腳本,也可以編寫自己的Jython腳本,測試各類 web項目、java項目,web service項目等;

對於統計的詳細信息,可以查看在log目錄下的data_machine_name.log的內容;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章