Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the .net performance testing framework Crank

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to use the .net performance testing framework Crank". In daily operation, I believe many people have doubts about how to use the .net performance testing framework Crank. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about how to use the .net performance testing framework Crank! Next, please follow the editor to study!

Crank is a new performance testing framework of Microsoft, which integrates a variety of benchmark testing tools, such as bombardier, wrk and so on.

Through a unified configuration, Crank can be converted into different benchmark tool commands for testing.

Install Crank

Run the following two commands to install cli (Controller) and Agent for Crank, respectively.

Dotnet tool update Microsoft.Crank.Controller-- version "0.2.0mura *"-- globaldotnet tool update Microsoft.Crank.Agent--version "0.2.0muri *"-- global

.net SDK 5.0environment is required

After the installation is completed, execute the command crank, which will print out the following configurable parameters and descriptions, or github to view the relevant parameters.

PS C:\ Users\ Stack\ Desktop > crankCrank Benchmarks ControllerThe Crank controller orchestrates benchmark jobs on Crank agents.Usage: Crank [command] [options] Options:-|-h |-- help Show help information-c |-- config Configuration file or url-s |-- scenario Scenario to execute-j |-- job Name of job to define-- profile Profile name-- script Execute a named script available in the configuration files. Can be used multiple times. -j |-- json Saves the results as json in the specified file. -- csv Saves the results as csv in the specified file. -- compare An optional filename to compare the results to. Can be used multiple times. -variable Variable-- sql Connection string of the SQL Server Database to store results in-- table Table name of the SQL Database to store results in-- session A logical identifier to group related jobs. -- description A string describing the job. -p |-- property Some custom key/value that will be added to the results, .e.g. -property arch=arm-property os=linux

Execute the crank-agent to start the agent services required for the benchmark. Github to view the relevant parameter description.

PS C:\ Users\ Stack\ Desktop > crank-agentHosting environment: ProductionContent 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\ Now listening on: http://[::]:5010 creates Crank configuration file

The configuration file refers to the official hello.benchmarks.yml example

Bombardier.yml is introduced in the sample file. Because the environment is not friendly to the githubusercontent.com domain name, you can consider downloading bombardier.yml locally, introducing imports into the local path, or directly adding the contents of the file to the new configuration file.

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

Using the recommended imports file in production, the benchmark can be completed with a small amount of configuration in the crank configuration file, and different Microsoft.Crank.Jobs.XXX/XXX.yml can be introduced to test based on different benchmarking tools.

The other test tool configuration files are under https://github.com/dotnet/crank/blob/main/src/Microsoft.Crank.XXX.

Variables: headers: none:''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" 'html:'-- header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/* Qroom0.8 "--header" Connection: keep-alive "'json:'-- header" Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/* Qroom0.7 "--header" Connection: keep-alive "'connectionclose:'-- header" Connection: close "'presetHeaders: nonejobs: bombardier: source: repository: https://github.com/dotnet/crank.git branchOrCommit: main project: src/Microsoft.Crank.Jobs.Bombardier/Microsoft.Crank.Jobs.Bombardier.csproj sourceKey: bombardier noBuild: true readyStateText: Bombardier Client waitForExit: true variables: connections: 256 # Settings Number of connections warmup: 15 # set test prefetch times duration: 15 # set test time requests: 0 # set test request instances rate: 0 # set request frequency per second transport: fasthttp # | http1 | http2 settings use golang's fasthttp library to send http requests serverScheme: http serverAddress: localhost serverPort: 5000 path: bodyFile: # path or url for a file To use as the body content verb: # GET when nothing is specified customHeaders: [] # list of headers with the format:':' E.g. ['content-type: application/json'] 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! = empty%}-m {{verb}} {% endif%} "onConfigure: #-job.timeout = Number (job.variables.duration) + Number (job.variables.warmup) + 10 Server: source: # specifies the project to be tested. This article directly uses the local path localFolder:. Project: crank_demo.csproj readyStateText: Application started. # source: specify the remote warehouse address of the test project, and specify the branch # repository: https://github.com/dotnet/crank # branchOrCommit: main # project: samples/hello/hello.csproj # readyStateText: Application started.scenarios: # configure benchmark scenario crank_demo: # define the scheme name via branchOrCommit Specify this name when executing the crank command: application: job: server # specify the test project as server load: job: bombardier # specify the test tool bombardier variables: serverPort: 5000 # configure http service port path: / # configure http service address profiles: local: variables: serverAddress: localhost jobs: application: endpoints: -http://localhost:5010 load: endpoints:-http://localhost:5010 starts Crank-Agent

When you execute crank after starting agent, you will have the following action to install sdk

[09Current 29Current 05.263] ASP.NET: 6.0.0 (Current) [09Current 29Current 05.265] Creating custom global.json [09MAV 295.266] Desktop: 6.0.0 (Current) [09Current 29Current] Installing SDK '6.0.100'.

So specify one more dotnethome parameter when starting agent to avoid repeated installation of sdk.

Crank-agent-- dotnethome'C:\ Program Files\ dotnet' launch Crankcrank-- config.\ demo.benchmarks.yml-- scenario crank_demo-- profile local

-- scenario crank_demo: specifies the defined test scenario

-- profile local: sets the output result to be local, that is, the console output

You can specify the results to be output to a local json file (--output results.json) or to a database (--sql [connection-string]-- table [table-name]) through parameters.

Result output

Here, the log output during the stress test is omitted and the results are listed directly.

| | application |-|-| | CPU Usage (%) | 56 | | Cores usage (%) | 447 | Working Set (MB) | 140 | | Private Memory (MB) | 157 | | Build Time (ms) | | | 7232 | | Start Time (ms) | 91292 | | Published Size (KB) | 91292 | | .NET Core SDK Version | 6.0.100 | | ASP.NET Core Version | 6.0.0+ae1a6cb | | .NET Runtime Version | 6.0.0+4822e3c | | load |-|-- | -| | CPU Usage (%) | 46 | | Cores usage (%) | 370 | | Working Set (MB) | 29 | Private Memory (MB) | 30 | | Build Time (ms) | 11891 | | Start Time (ms) | 226 | Published Size (KB) | 68228 | | | .NET Core SDK Version | 3.1.415 | | ASP.NET Core Version | 3.1.21+458d974 | | .NET Runtime Version | 3.1.21+df8abc0 | | First Request (ms) | 185 | Requests | 912005 | Bad responses | 0 | Mean latency (us) | 4207 | | Max latency (us) | 138999 | | Requests/sec | | | 60305 | | Requests/sec (max) | 128523 | so far | The study on "how to use the .net performance testing framework Crank" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report