亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

nGrinder性能工具源碼安裝部署過(guò)程

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

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

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

nGrinder 由兩個(gè)主要的組件組成

  • Controller

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

  • Agent

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

一、前言

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

 二、源碼下載

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

在這里插入圖片描述

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

在這里插入圖片描述

三、本地配置

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

在這里插入圖片描述

打開目錄啟動(dòng)腳本:

在這里插入圖片描述

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

在這里插入圖片描述

四、IDEA 設(shè)置

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

在這里插入圖片描述

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

在這里插入圖片描述

點(diǎn)擊 Open as Project:

在這里插入圖片描述

打開一個(gè)新窗口:

在這里插入圖片描述

等待 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:

在這里插入圖片描述

選擇運(yùn)行方式:

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

選擇時(shí)時(shí)更新運(yùn)行:

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

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

-Xms1024m -Xmx1024m -XX:MaxPermSize=200m

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

在這里插入圖片描述

點(diǎn)擊確定:

在這里插入圖片描述

啟動(dòng)項(xiàng)目:

在這里插入圖片描述

五、啟動(dòng)驗(yàn)證

打開瀏覽器驗(yàn)證是否成功:

http://localhost:8081/ngrinder/login

在這里插入圖片描述

登錄成功:

在這里插入圖片描述

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

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

在這里插入圖片描述

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

<version>2.4.16</version>

七、模仿編寫腳本

通過(guò)平臺(tái)生成腳本:

在這里插入圖片描述

點(diǎn)擊 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 腳本:

在這里插入圖片描述

輸入名字點(diǎn)擊保存即可:

在這里插入圖片描述

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

在這里插入圖片描述

點(diǎn)擊運(yùn)行:

在這里插入圖片描述

可以看到提示:

在這里插入圖片描述

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

在這里插入圖片描述

再次點(diǎn)擊:

在這里插入圖片描述

運(yùn)行結(jié)果如下:

在這里插入圖片描述

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

八、小結(jié)

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

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

相關(guān)文章

  • IDEA開啟Run Dashboard的配置詳解

    IDEA開啟Run Dashboard的配置詳解

    這篇文章主要介紹了IDEA開啟Run Dashboard的配置詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • 各種語(yǔ)言、服務(wù)器301跳轉(zhuǎn)代碼全集

    各種語(yǔ)言、服務(wù)器301跳轉(zhuǎn)代碼全集

    這篇文章主要介紹了各種語(yǔ)言、服務(wù)器301跳轉(zhuǎn)代碼全集,本文講解了IIS下301設(shè)置、ASP下的301轉(zhuǎn)向代碼、ASP.Net下的301轉(zhuǎn)向代碼、PHP下的301轉(zhuǎn)向代碼 、CGI Perl下的301轉(zhuǎn)向代碼、JSP下的301轉(zhuǎn)向代碼等內(nèi)容,需要的朋友可以參考下
    2015-04-04
  • 矩形相交以及求出相交的區(qū)域的原理解析

    矩形相交以及求出相交的區(qū)域的原理解析

    問(wèn)題:給定兩個(gè)矩形A和B,矩形A的左上角坐標(biāo)為(Xa1,Ya1),右下角坐標(biāo)為(Xa2,Ya2),矩形B的左上角坐標(biāo)為(Xb1,Yb1),右下角 坐標(biāo)為(Xb2,Yb2)。
    2011-01-01
  • OAuth從1.0到2.1的發(fā)展之路

    OAuth從1.0到2.1的發(fā)展之路

    OAUTH協(xié)議為用戶資源的授權(quán)提供了一個(gè)安全的、開放而又簡(jiǎn)易的標(biāo)準(zhǔn)。簡(jiǎn)單來(lái)說(shuō)就是提供除了"賬戶密碼"驗(yàn)證方式以外的驗(yàn)證授權(quán)方式。這篇文章介紹了OAuth從1.0到2.1的發(fā)展之路,感興趣的同學(xué)可以收藏一下
    2021-11-11
  • IntelliJ IDEA 2020.1配置svn的圖文教程

    IntelliJ IDEA 2020.1配置svn的圖文教程

    這篇文章主要介紹了IntelliJ IDEA 2020.1配置svn的圖文教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-11-11
  • Git的基礎(chǔ)文件操作初始化查看添加提交示例教程

    Git的基礎(chǔ)文件操作初始化查看添加提交示例教程

    這篇文章主要為大家介紹了Git的基礎(chǔ)文件操作初始化查看添加提交示例教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-04-04
  • 詳細(xì)解析Webpack是怎么運(yùn)行的

    詳細(xì)解析Webpack是怎么運(yùn)行的

    這篇文章主要介紹了Webpack是怎么運(yùn)行的,打包順序是怎樣的,非常基礎(chǔ)且非常重要的知識(shí)點(diǎn)
    2020-02-02
  • 聯(lián)邦學(xué)習(xí)FedAvg中模型聚合過(guò)程的理解分析

    聯(lián)邦學(xué)習(xí)FedAvg中模型聚合過(guò)程的理解分析

    這篇文章主要為大家介紹了FedAvg中模型聚合過(guò)程的理解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • 打造博客園(cnblogs)超級(jí)自定義界面

    打造博客園(cnblogs)超級(jí)自定義界面

    有部分網(wǎng)友提出想了解一下像我這樣的高度訂制化博客界面是如何做出來(lái)的。所以在這里給大家分享一下經(jīng)驗(yàn)。
    2009-12-12
  • vscode 配置eslint和prettier正確方法

    vscode 配置eslint和prettier正確方法

    ESLint 是一款語(yǔ)法檢測(cè)工具而prettier 是一個(gè)代碼格式化插件,今天給大家分享vscode 配置eslint和prettier正確方法,感興趣的朋友一起看看吧
    2021-07-07

最新評(píng)論