偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

.Net Crank性能測(cè)試入門

開發(fā) 后端
Crank 是微軟新出的一個(gè)性能測(cè)試框架,集成了多種基準(zhǔn)測(cè)試工具,如bombardier、wrk等。Crank通過統(tǒng)一的配置,可以轉(zhuǎn)換成不同基準(zhǔn)測(cè)試工具命令進(jìn)行測(cè)試。可參考Bombardier Job實(shí)現(xiàn)。

[[437057]]

Crank 是微軟新出的一個(gè)性能測(cè)試框架,集成了多種基準(zhǔn)測(cè)試工具,如bombardier、wrk等。

Crank通過統(tǒng)一的配置,可以轉(zhuǎn)換成不同基準(zhǔn)測(cè)試工具命令進(jìn)行測(cè)試。可參考Bombardier Job實(shí)現(xiàn)。

安裝Crank

運(yùn)行如下兩個(gè)命令分別安裝Crank的cli(Controller)和Agent。

  1. dotnet tool update Microsoft.Crank.Controller --version "0.2.0-*" --global 
  2.  
  3. dotnet tool update Microsoft.Crank.Agent--version "0.2.0-*" --global 

需要.Net SDK 5.0環(huán)境

安裝完成后執(zhí)行命令crank,會(huì)打印出如下可以配置的參數(shù)和介紹,或者github查看相關(guān)參數(shù)介紹。

  1. PS C:\Users\Stack\Desktop> crank 
  2. Crank Benchmarks Controller 
  3.  
  4. The Crank controller orchestrates benchmark jobs on Crank agents. 
  5.  
  6. Usage: Crank [command] [options] 
  7.  
  8. Options: 
  9.   -?|-h|--help         Show help information 
  10.   -c|--config          Configuration file or url 
  11.   -s|--scenario        Scenario to execute 
  12.   -j|--job             Name of job to define 
  13.   --profile            Profile name 
  14.   --script             Execute a named script available in the configuration files. Can be used multiple times. 
  15.   -j|--json            Saves the results as json in the specified file. 
  16.   --csv                Saves the results as csv in the specified file. 
  17.   --compare            An optional filename to compare the results to. Can be used multiple times. 
  18.   --variable           Variable 
  19.   --sql                Connection string of the SQL Server Database to store results in 
  20.   --table              Table name of the SQL Database to store results in 
  21.   --session            A logical identifier to group related jobs. 
  22.   --description        A string describing the job. 
  23.   -p|--property        Some custom key/value that will be added to the results, .e.g. --property arch=arm --property 
  24.                        os=linux 

執(zhí)行crank-agent,啟動(dòng)基準(zhǔn)測(cè)試所需的代理服務(wù)。github查看相關(guān)參數(shù)介紹。

  1. PS C:\Users\Stack\Desktop> crank-agent 
  2. Hosting environment: Production 
  3. Content root path: C:\Users\Stack\.dotnet\tools\.store\microsoft.crank.agent\0.2.0-alpha.21567.1\microsoft.crank.agent\0.2.0-alpha.21567.1\tools\net5.0\any
  4. Now listening on: http://[::]:5010 

創(chuàng)建Crank配置文件

配置文件參考官方hello.benchmarks.yml示例

示例文件中引入了bombardier.yml,由于大環(huán)境對(duì)githubusercontent.com域名不太友好,可以考慮將bombardier.yml下載到本地,imports引入本地路徑或者直接將文件內(nèi)容加入到新建的配置文件。

  1. imports: 
  2.   -https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Bombardier/bombardier.yml 

生產(chǎn)中使用推薦imports文件的方式,crank配置文件中做少量配置就可以完成基準(zhǔn)測(cè)試,并且可以引入不同的Microsoft.Crank.Jobs.XXX/XXX.yml,基于不同的基準(zhǔn)測(cè)試工具進(jìn)行測(cè)試。

其他測(cè)試工具配置文件都在https://github.com/dotnet/crank/blob/main/src/Microsoft.Crank.XXX下。

  1. variables: 
  2.   headers: 
  3.     none: '' 
  4.     plaintext: '--header "Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7" --header "Connection: keep-alive"' 
  5.     html: '--header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" --header "Connection: keep-alive"' 
  6.     json: '--header "Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7" --header "Connection: keep-alive"' 
  7.     connectionclose: '--header "Connection: close"' 
  8.   presetHeaders: none 
  9.  
  10. jobs: 
  11.   bombardier: 
  12.     source: 
  13.       repository: https://github.com/dotnet/crank.git 
  14.       branchOrCommit: main 
  15.       project: src/Microsoft.Crank.Jobs.Bombardier/Microsoft.Crank.Jobs.Bombardier.csproj 
  16.       sourceKey: bombardier 
  17.       noBuild: true 
  18.     readyStateText: Bombardier Client 
  19.     waitForExit: true 
  20.     variables: 
  21.       connections: 256 #設(shè)置連接數(shù) 
  22.       warmup: 15 #設(shè)置測(cè)試預(yù)熱次數(shù) 
  23.       duration: 15 #設(shè)置測(cè)試時(shí)間 
  24.       requests: 0 #設(shè)置測(cè)試請(qǐng)求實(shí)例數(shù) 
  25.       rate: 0 #設(shè)置每秒請(qǐng)求頻率 
  26.       transport: fasthttp # | http1 | http2  設(shè)置使用golang的fasthttp庫發(fā)送http請(qǐng)求 
  27.       serverScheme: http 
  28.       serverAddress: localhost 
  29.       serverPort: 5000 
  30.       path:  
  31.       bodyFile: # path or url for a file to use as the body content 
  32.       verb: # GET when nothing is specified 
  33.       customHeaders: [ ] # list of headers with the format: '<name1>: <value1>', e.g. [ 'content-type: application/json' ] 
  34.     arguments: "-c {{connections}} -w {{warmup}} -d {{duration}} -n {{requests}} --insecure -l {% if rate != 0 %} --rate {{ rate }} {% endif %} {% if transport %} --{{ transport}} {% endif %} {{headers[presetHeaders]}} {% for h in customHeaders %}{% assign s = h | split : ':' %}--header \"{{ s[0] }}: {{ s[1] | strip }}\" {% endfor %} {% if serverUri == blank or serverUri == empty %} {{serverScheme}}://{{serverAddress}}:{{serverPort}}{{path}} {% else %} {{serverUri}}:{{serverPort}}{{path}} {% endif %} {% if bodyFile != blank and bodyFile != empty %} -f {{bodyFile}} {% endif %}  {% if verb != blank and verb != empty %} -m {{verb}} {% endif %}" 
  35.     onConfigure:  
  36.       # - job.timeout = Number(job.variables.duration) + Number(job.variables.warmup) + 10; 
  37.  
  38.   server: 
  39.     source: #指定需要測(cè)試的項(xiàng)目,本文直接使用本地路徑 
  40.       localFolder: . 
  41.       project: crank_demo.csproj 
  42.     readyStateText: Application started. 
  43.     # source: 指定測(cè)試項(xiàng)目的遠(yuǎn)程倉庫地址,并通過branchOrCommit指定分支 
  44.     #   repository: https://github.com/dotnet/crank 
  45.     #   branchOrCommit: main 
  46.     #   project: samples/hello/hello.csproj 
  47.     # readyStateText: Application started. 
  48.  
  49. scenarios: #配置基準(zhǔn)測(cè)試場(chǎng)景 
  50.   crank_demo: #定義方案名,執(zhí)行crank命令時(shí)指定該名稱 
  51.     application:  
  52.       job: server # 指定測(cè)試項(xiàng)目為上面定義的server 
  53.     load
  54.       job: bombardier # 指定測(cè)試工具bombardier 
  55.       variables: 
  56.         serverPort: 5000 #配置http服務(wù)端口 
  57.         path: / #配置http服務(wù)地址 
  58.  
  59. profiles: 
  60.   local
  61.     variables: 
  62.       serverAddress: localhost 
  63.     jobs:  
  64.       application: 
  65.         endpoints:  
  66.           - http://localhost:5010 
  67.       load
  68.         endpoints:  
  69.           - http://localhost:5010 

啟動(dòng)Crank-Agent

啟動(dòng)agent后執(zhí)行crank,會(huì)有一個(gè)如下安裝sdk的動(dòng)作

  1. [09:29:05.261] Runtime: 6.0.0 (Current
  2. [09:29:05.262] SDK: 6.0.100 (Current
  3. [09:29:05.263] ASP.NET: 6.0.0 (Current
  4. [09:29:05.265] Creating custom global.json 
  5. [09:29:05.266] Desktop: 6.0.0 (Current
  6. [09:29:05.266] Installing SDK '6.0.100' ... 

所以啟動(dòng)agent時(shí)多指定一個(gè)dotnethome參數(shù),避免重復(fù)安裝sdk。

  1. crank-agent --dotnethome 'C:\Program Files\dotnet' 

啟動(dòng)Crank

crank --config .\demo.benchmarks.yml --scenario crank_demo --profile local

--scenario crank_demo: 指定定義的測(cè)試場(chǎng)景

--profile local :設(shè)置輸出結(jié)果到本地,即控制臺(tái)輸出

可以通過參數(shù)指定結(jié)果輸出到本地json文件(--output results.json )或者數(shù)據(jù)庫(--sql [connection-string] --table [table-name])

結(jié)果輸出

這里省略壓測(cè)期間的日志輸出,直接列出結(jié)果。

  1. | application           |               | 
  2. --------------------- | ------------- | 
  3. | CPU Usage (%)         | 56            | 
  4. | Cores usage (%)       | 447           | 
  5. | Working Set (MB)      | 140           | 
  6. | Private Memory (MB)   | 157           | 
  7. | Build Time (ms)       | 7,232         | 
  8. | Start Time (ms)       | 501           | 
  9. | Published Size (KB)   | 91,292        | 
  10. | .NET Core SDK Version | 6.0.100       | 
  11. | ASP.NET Core Version  | 6.0.0+ae1a6cb | 
  12. | .NET Runtime Version  | 6.0.0+4822e3c | 
  13.  
  14.  
  15. load                  |                |  
  16. --------------------- | -------------- | 
  17. | CPU Usage (%)         | 46             |  
  18. | Cores usage (%)       | 370            |  
  19. | Working Set (MB)      | 29             | 
  20. | Private Memory (MB)   | 30             | 
  21. | Build Time (ms)       | 11,891         | 
  22. | Start Time (ms)       | 226            | 
  23. | Published Size (KB)   | 68,228         | 
  24. | .NET Core SDK Version | 3.1.415        | 
  25. | ASP.NET Core Version  | 3.1.21+458d974 | 
  26. | .NET Runtime Version  | 3.1.21+df8abc0 | 
  27. First Request (ms)    | 185            | 
  28. | Requests              | 912,005        | 
  29. | Bad responses         | 0              | 
  30. | Mean latency (us)     | 4,207          | 
  31. Max latency (us)      | 138,999        | 
  32. | Requests/sec          | 60,305         | 
  33. | Requests/sec (max)    | 128,523        | 

更多

crank readme: https://github.com/dotnet/crank/blob/main/docs/README.md

Benchmarks crank為Benchmarks重構(gòu)版本

 

本文示例代碼: https://github.com/MayueCif/crank_demo

 

責(zé)任編輯:武曉燕 來源: 分布式應(yīng)用運(yùn)行時(shí)
相關(guān)推薦

2022-11-24 09:01:26

HTTPHertz架構(gòu)

2011-07-19 09:35:46

.Net

2021-05-07 07:27:51

Python測(cè)試工具

2009-11-12 09:25:21

ADO.NET連接池

2009-12-30 11:03:26

ADO.Net性能

2010-07-13 09:10:26

.NETMonoJava

2023-08-31 08:36:52

.NET性能測(cè)試開源

2009-09-18 13:05:59

.NET CLR

2011-03-15 16:34:36

Iptables性能

2010-12-31 13:30:12

2020-05-18 07:00:00

性能測(cè)試壓力測(cè)試負(fù)載測(cè)試

2011-06-08 16:59:04

性能測(cè)試載測(cè)試壓力測(cè)試

2019-08-21 10:53:29

.NET性能優(yōu)化

2011-12-15 09:55:47

javanio

2009-09-22 17:41:07

Hibernate性能

2009-09-16 09:37:47

ASP.NET和PHP

2014-07-28 09:52:14

PythonPython性能

2009-09-04 17:27:46

C# DES

2009-07-24 15:41:00

ASP.NET編程入門

2010-06-02 08:53:51

.NET 4并行編程
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)