最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

nGrinder性能工具源碼安裝部署過程

 更新時間:2021年05月31日 16:19:40   作者:zuozewei  
nGrinder是NHN公司用Java語言開發(fā)的一款的基于Grinder開發(fā)的開源B/S Web性能測試平臺,具有友好簡潔的用戶界面和分布式測試功能,本文給大家分享nGrinder性能工具源碼安裝部署過程,一起看看吧

nGrinderr(version: 3.4.1)是NAVER(韓國最大互聯(lián)網(wǎng)公司NHN旗下搜索引擎網(wǎng)站)開源的性能測試工具,直接部署成web服務(wù),支持多用戶使用,可擴(kuò)展性好,可自定義plugin。

nGrinder 是一款在一系列機(jī)器上執(zhí)行 Groovy 或 Jython 測試腳本的應(yīng)用,內(nèi)部引擎是基于 Grinder。 nGrinder 使用 controller 和 agent 分別包裝了 Grinder 的 console 和 agent ,而且擴(kuò)展了多種功能使其能夠支持并發(fā)測試。

nGrinder 由兩個主要的組件組成

  • Controller

提供性能測試的web接口。
協(xié)調(diào)測試進(jìn)程。
整理和顯示測試的統(tǒng)計結(jié)果
讓用戶創(chuàng)建和修改腳本。

  • Agent

在代理服務(wù)器上加載運行測試進(jìn)程和線程。
監(jiān)控目標(biāo)機(jī)器的系統(tǒng)性能(例如:CPU/MEMORY/網(wǎng)卡/磁盤)

一、前言

  • 為了更好了解 nGrinder 怎么工作?
  • 為二次開發(fā)做準(zhǔn)備

 二、源碼下載

下載地址:https://github.com/naver/ngrinder/releases

在這里插入圖片描述

也可以直接通過:https://github.com/naver/ngrinder.git 方式

在這里插入圖片描述

三、本地配置

這我們演示直接使用下載 zip 包進(jìn)行安裝:

在這里插入圖片描述

打開目錄啟動腳本:

在這里插入圖片描述

等待執(zhí)行成功便把如下 jar 包安裝到本地倉庫:

在這里插入圖片描述

四、IDEA 設(shè)置

打開 IDEA 開發(fā)工具:

在這里插入圖片描述

點擊文件導(dǎo)入 Project:

在這里插入圖片描述

點擊 Open as Project:

在這里插入圖片描述

打開一個新窗口:

在這里插入圖片描述

等待 maven 加載相應(yīng)的 jar。

修改代碼:

在這里插入圖片描述

具體代碼如下:

package org.ngrinder.perftest.service;
import org.ngrinder.infra.config.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
 * Dynamic creation of {@link PerfTestService} depending on the cluster enable or disable.
 *
 * @author JunHo Yoon
 * @since 3.1
 */
@Configuration
@Profile("production")
@EnableScheduling
@EnableTransactionManagement
@EnableAspectJAutoProxy
public class PerfTestServiceConfig implements ApplicationContextAware {
   @Autowired
   private Config config;
   private ApplicationContext applicationContext;
   /**
    * Create PerTest service depending on cluster mode.
    *
    * @return {@link PerfTestService}
    */
   @Bean(name = "perfTestService")
   public PerfTestService perfTestService() {
      if (config.isClustered()) {
         return applicationContext.getAutowireCapableBeanFactory().createBean(ClusteredPerfTestService.class);
      } else {
         return applicationContext.getAutowireCapableBeanFactory().createBean(PerfTestService.class);
      }
//    return applicationContext.getAutowireCapableBeanFactory().createBean(
//          config.isClustered() ? ClusteredPerfTestService.class : PerfTestService.class);
   }
   @Override
   public void setApplicationContext(ApplicationContext applicationContext) {
      this.applicationContext = applicationContext;
   }
}

再次配置 Tomcat:

在這里插入圖片描述

選擇運行方式:

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

選擇時時更新運行:

在這里插入圖片描述
在這里插入圖片描述

注意最好是加上 JVM 啟動參數(shù):

-Xms1024m -Xmx1024m -XX:MaxPermSize=200m

防止內(nèi)存出現(xiàn)異常

在這里插入圖片描述

點擊確定:

在這里插入圖片描述

啟動項目:

在這里插入圖片描述

五、啟動驗證

打開瀏覽器驗證是否成功:

http://localhost:8081/ngrinder/login

在這里插入圖片描述

登錄成功:

在這里插入圖片描述

六、使用源碼調(diào)試簡單腳本

script-sample工程下的 pom.xml文件增加:

在這里插入圖片描述

代碼如下:

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.12</version>
   <scope>test</scope>
</dependency>

再次在 idea 中全局搜索:

groovy-all

在這里插入圖片描述

查看版本號,統(tǒng)一修改為:

<version>2.4.16</version>

七、模仿編寫腳本

通過平臺生成腳本:

在這里插入圖片描述

點擊 R HEAD

在這里插入圖片描述

查看腳本:

importstatic net.grinder.script.Grinder.grinder
importstatic org.junit.Assert.*
importstatic org.hamcrest.Matchers.*
import net.grinder.plugin.http.HTTPRequest
import net.grinder.plugin.http.HTTPPluginControl
import net.grinder.script.GTest
import net.grinder.script.Grinder
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
// import static net.grinder.util.GrinderUtils.* // You can use this if you're using nGrinder after 3.2.3
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import java.util.Date
import java.util.List
import java.util.ArrayList
importHTTPClient.Cookie
importHTTPClient.CookieModule
importHTTPClient.HTTPResponse
importHTTPClient.NVPair


/**
 * A simple example using the HTTP plugin that shows the retrieval of a
 * single page via HTTP.
 *
 * This script is automatically generated by ngrinder.
 *
 * @author admin
 */

@RunWith(GrinderRunner)
classTestRunner{

publicstaticGTest test
publicstaticHTTPRequest request
publicstaticNVPair[] headers = []
publicstaticNVPair[] params= []
publicstaticCookie[] cookies = []

@BeforeProcess
publicstaticvoid beforeProcess() {
HTTPPluginControl.getConnectionDefaults().timeout = 6000
		test = newGTest(1, "www.baidu.com")
		request = newHTTPRequest()
		grinder.logger.info("before process.");
}


@BeforeThread
publicvoid beforeThread() {
		test.record(this, "test")
		grinder.statistics.delayReports=true;
		grinder.logger.info("before thread.");
}


@Before
publicvoid before() {
		request.setHeaders(headers)
		cookies.each { CookieModule.addCookie(it, HTTPPluginControl.getThreadHTTPClientContext()) }
		grinder.logger.info("before thread. init headers and cookies");
}


@Test
publicvoid test(){
HTTPResponse result = request.GET("https://www.baidu.com/", params)

if(result.statusCode == 301|| result.statusCode == 302) {
			grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode);

} else{
			assertThat(result.statusCode, is(200));
}
}
}

復(fù)制腳本:
在 idea 中新建腳本:

在這里插入圖片描述

選擇 Groovy 腳本:

在這里插入圖片描述

輸入名字點擊保存即可:

在這里插入圖片描述

新建完畢把剛才腳本復(fù)制過來修改下方法名稱:

在這里插入圖片描述

點擊運行:

在這里插入圖片描述

可以看到提示:

在這里插入圖片描述

在 Idea 菜單欄->Run->Edit Configurations->Default->Junit->在VM options 填寫自定義配置,點擊 Apply 按鈕保存配置即生效:

在這里插入圖片描述

再次點擊:

在這里插入圖片描述

運行結(jié)果如下:

在這里插入圖片描述

到這里本機(jī)腳本調(diào)試成功。

八、小結(jié)

下次再次分享本地參數(shù)化與 Post 請求

以上就是性能工具之 nGrinder 源碼安裝的詳細(xì)內(nèi)容,更多關(guān)于nGrinder 源碼安裝的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Kettle下載與安裝保姆級教程(最新)

    Kettle下載與安裝保姆級教程(最新)

    Kettle是一個實現(xiàn)ETL開發(fā)的一款開發(fā)工具,Spoon是Kettle工具提供的圖形化界面,它由Java開發(fā),支持跨平臺運行,本文給大家分享Kettle下載與安裝配置教程,感興趣的朋友一起看看吧
    2022-11-11
  • 鴻蒙中@State的原理使用詳解(HarmonyOS 5)

    鴻蒙中@State的原理使用詳解(HarmonyOS 5)

    @State是 HarmonyOS ArkTS 框架中用于管理組件狀態(tài)的核心裝飾器,其核心作用是實現(xiàn)數(shù)據(jù)驅(qū)動 UI 的響應(yīng)式編程模式,本文給大家介紹鴻蒙中@State的原理詳解,感興趣的朋友一起看看吧
    2025-04-04
  • OpenManus本地部署實戰(zhàn)親測有效完全免費(最新推薦)

    OpenManus本地部署實戰(zhàn)親測有效完全免費(最新推薦)

    文章介紹了如何在本地部署OpenManus大語言模型,包括環(huán)境搭建、LLM編程接口配置和測試步驟,本文給大家講解的非常詳細(xì),感興趣的朋友一起看看吧
    2025-03-03
  • 輕量級思維導(dǎo)圖XMind?2023免費激活教程

    輕量級思維導(dǎo)圖XMind?2023免費激活教程

    這篇文章主要介紹了輕量級思維導(dǎo)圖XMind?2023免費激活教程,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-07-07
  • svn 常用命令集合

    svn 常用命令集合

    SVN是subversion的縮寫,是一個開放源代碼的版本控制系統(tǒng),通過采用分支管理系統(tǒng)的高效管理,簡而言之就是用于多個人共同開發(fā)同一個項目,實現(xiàn)共享資源,實現(xiàn)最終集中式的管理
    2020-07-07
  • 死鎖問題詳解

    死鎖問題詳解

    本文詳細(xì)介紹了死鎖,例如死鎖的概念、產(chǎn)生死鎖的條件、如何預(yù)防死鎖等等,有需要的朋友可以自行參考本篇文章,希望對你有所幫助
    2021-08-08
  • UE、UI、UCD、Interaction Design、UED、UX、HCI、Usability,IA

    UE、UI、UCD、Interaction Design、UED、UX、HCI、Usability,IA

    最近,總是纏綿在UE、UI、UCD、Interaction Design、UED、UX、HCI、Usability,IA等等名詞間,我一邊搜集,一邊整理,現(xiàn)在放在一次統(tǒng)一解釋,以便比較,以正視聽。很多地方未必準(zhǔn)確,歡迎提出修改意見。
    2009-04-04
  • 2022最新騰訊輕量云?debian?10?安裝pve教程詳解

    2022最新騰訊輕量云?debian?10?安裝pve教程詳解

    這篇文章主要介紹了騰訊輕量云?debian?10?安裝pve教程?2022,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-10-10
  • 使用百度云加速后網(wǎng)站打開速度慢、廣告不顯示的解決方法

    使用百度云加速后網(wǎng)站打開速度慢、廣告不顯示的解決方法

    這篇文章主要介紹了使用百度云加速后網(wǎng)站打開速度慢、廣告不顯示的解決方法,需要的朋友可以參考下
    2015-09-09
  • git工作區(qū)暫存區(qū)與版本庫基本理解及提交流程全解

    git工作區(qū)暫存區(qū)與版本庫基本理解及提交流程全解

    這篇文章主要為大家介紹了git工作區(qū)暫存區(qū)與版本庫基本理解及提交流程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2022-04-04

最新評論

论坛| 海原县| 交口县| 阿勒泰市| 龙井市| 寿宁县| 囊谦县| 邵东县| 龙口市| 陆川县| 兴城市| 阜阳市| 广饶县| 十堰市| 剑河县| 合水县| 台安县| 都昌县| 黔江区| 崇州市| 邻水| 杂多县| 孟津县| 延边| 周至县| 阳西县| 江城| 惠来县| 清苑县| 噶尔县| 通山县| 江阴市| 乐亭县| 孝感市| 德格县| 将乐县| 蓝田县| 灵寿县| 青岛市| 内江市| 巫山县|