├── README.md ├── bombardier ├── run.cmd └── run.sh ├── iperf3 └── docker-compose.yml ├── java-reactor-netty ├── .dockerignore ├── .gitignore ├── Dockerfile ├── build.cmd ├── build.sh ├── pom.xml ├── run.cmd ├── run.sh └── src │ └── main │ └── java │ └── com │ └── mycompany │ └── app │ └── App.java ├── js-axios ├── .dockerignore ├── .gitignore ├── Dockerfile ├── app.js ├── build.cmd ├── build.sh ├── package-lock.json ├── package.json ├── run.cmd └── run.sh ├── js-azure-core-http ├── .dockerignore ├── .gitignore ├── Dockerfile ├── app.js ├── build.cmd ├── build.sh ├── package-lock.json ├── package.json ├── run.cmd └── run.sh ├── js-http ├── .dockerignore ├── .gitignore ├── Dockerfile ├── app.js ├── build.cmd ├── build.sh ├── package-lock.json ├── package.json ├── run.cmd └── run.sh ├── js-node-fetch ├── .dockerignore ├── .gitignore ├── Dockerfile ├── app.js ├── build.cmd ├── build.sh ├── package-lock.json ├── package.json ├── run.cmd └── run.sh ├── js-sockets ├── .dockerignore ├── .gitignore ├── Dockerfile ├── app.js ├── build.cmd ├── build.sh ├── package-lock.json ├── package.json ├── run.cmd └── run.sh ├── net-http-client-put ├── .dockerignore ├── .gitignore ├── Dockerfile ├── Program.cs ├── app.csproj ├── app.sln ├── build.cmd ├── build.sh ├── run.cmd └── run.sh ├── net-http-client ├── .dockerignore ├── .gitignore ├── Dockerfile ├── Program.cs ├── app.csproj ├── app.sln └── docker-compose.yml ├── net-sockets ├── .dockerignore ├── .gitignore ├── Dockerfile ├── Program.cs ├── app.csproj ├── build.cmd ├── build.sh ├── run.cmd └── run.sh ├── python-aiohttp ├── .dockerignore ├── .gitignore ├── Dockerfile ├── app.py ├── docker-compose.yml └── requirements.txt ├── python-http-client-put ├── .dockerignore ├── Dockerfile ├── app.py ├── build.cmd ├── build.sh ├── requirements.txt ├── run.cmd └── run.sh ├── python-raw-sockets ├── .dockerignore ├── Dockerfile ├── app.py ├── docker-compose.yml └── requirements.txt ├── python-requests ├── .dockerignore ├── .gitignore ├── Dockerfile ├── app.py ├── docker-compose.yml └── requirements.txt ├── python-sockets ├── .dockerignore ├── Dockerfile ├── app.py ├── build.cmd ├── build.sh ├── docker-compose.yml ├── requirements.txt ├── run.cmd └── run.sh ├── server ├── .dockerignore ├── .gitignore ├── Dockerfile ├── Program.cs ├── Properties │ └── launchSettings.json ├── app.csproj ├── app.sln ├── docker-compose.yml └── testCert.pfx ├── wrk └── docker-compose.yml └── wrk2 └── run.sh /README.md: -------------------------------------------------------------------------------- 1 | # HTTP GET performance comparison 2 | 3 | Client was run on Azure DS1_V2 (1 core) for parity since Python and JS are limited to a single CPU. Server was run on Azure DS3_V2 (4 cores) to ensure server was not the bottleneck. 4 | 5 | ![image](https://user-images.githubusercontent.com/9459391/75201357-1c60de80-571d-11ea-8a29-a33f6eee1059.png) 6 | 7 | | Client | Description | Connections | Requests Per Second | 8 | |---------------------|-----------------------------------|-------------|---------------------| 9 | | wrk | Benchmarking tool (written in C) | 256 | 71,284 | 10 | | bombardier | Benchmarking tool (written in go) | 256 | 62,988 | 11 | | net-sockets | .NET Core Async Sockets | 64 | 67,231 | 12 | | net-http-client | .NET Core Async HttpClient | 64 | 28,099 | 13 | | java-reactor-netty | Java Reactor Netty | 64 | 26,546 | 14 | | js-sockets | JavaScript net.Socket | 128 | 64,795 | 15 | | js-http | JavaScript http | 64 | 13,971 | 16 | | js-node-fetch | JavaScript node-fetch | 64 | 8,430 | 17 | | python-sockets | Python Async Sockets | 256 | 33,652 | 18 | | python-aiohttp | Python Async AioHttp | 32 | 2,135 | 19 | 20 | `wrk` is a benchmarking tool written in C and designed for maximum throughput. It represents the theoretical maximum performance of any language's HTTP client implementation. 21 | 22 | `bombardier` is an alternative benchmarking tool written in Go. 23 | 24 | `net-sockets`, `js-sockets`, and `python-raw-sockets` use raw sockets to send an HTTP GET message and read the response bytes. The request message bytes are pre-computed and reused for every request, and the response bytes are read but not parsed. This represents the theoretical maximum performance of a given language's HTTP client implementation. (`python-sockets` uses Python's async socket interface from the stdlib's `asyncio` library.) 25 | 26 | `net-http-client` uses the `System.Net.HttpClient` client. 27 | 28 | `java-reactor-netty` uses the `reactor-netty` client. 29 | 30 | `js-http` uses the `http` client, and `js-node-fetch` uses the `node-fetch` client. 31 | 32 | `python-aiohttp` uses the `aiohttp` client. 33 | 34 | # Repro Steps 35 | 36 | For the most accurate results, the server and client apps should be run on separate machines. 37 | 38 | ## Server 39 | The server is a tiny ASP.NET Core application which listens on port 5000 and reponds to all requests with the following response: 40 | 41 | ``` 42 | HTTP/1.1 200 OK 43 | Date: Fri, 07 Feb 2020 20:15:32 GMT 44 | Content-Type: text/plain 45 | Server: Kestrel 46 | Content-Length: 13 47 | 48 | Hello, World! 49 | ``` 50 | 51 | 1. `git clone https://github.com/mikeharder/http-get-perf` 52 | 2. `cd http-get-perf/server` 53 | 3. `docker-compose run --rm server` 54 | 4. The same instance of the server can be re-used for all test runs 55 | 56 | ## Client 57 | The client apps make HTTP GET requests to the server in a loop and measure throughput. Example: 58 | 59 | ``` 60 | ~/http-get-perf/python-aiohttp$ docker-compose run --rm client http://server-host-or-ip:5000 61 | === Parameters === 62 | Url: http://server-host-or-ip:5000 63 | Parallel: 32 64 | Warmup: 10 65 | Duration: 10 66 | 67 | === Warmup === 68 | Completed 15,680 requests in 10.03 seconds (1,564 req/s) 69 | 70 | === Test === 71 | Completed 17,055 requests in 10.03 seconds (1,701 req/s) 72 | ``` 73 | 74 | 1. `git clone https://github.com/mikeharder/http-get-perf` 75 | 2. `cd http-get-perf/` 76 | 3. `docker-compose run --rm client http://:5000` 77 | -------------------------------------------------------------------------------- /bombardier/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host alpine/bombardier -c 256 %* 2 | -------------------------------------------------------------------------------- /bombardier/run.sh: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host alpine/bombardier -c 256 "$@" 2 | -------------------------------------------------------------------------------- /iperf3/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | iperf3: 4 | image: networkstatic/iperf3 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /java-reactor-netty/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | 9 | target 10 | -------------------------------------------------------------------------------- /java-reactor-netty/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | dependency-reduced-pom.xml 8 | buildNumber.properties 9 | .mvn/timing.properties 10 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 11 | .mvn/wrapper/maven-wrapper.jar 12 | 13 | .classpath 14 | .project 15 | .settings 16 | -------------------------------------------------------------------------------- /java-reactor-netty/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3-jdk-11 as build 2 | 3 | # Copy pom.xml and install dependencies 4 | WORKDIR /app 5 | COPY pom.xml . 6 | RUN mvn dependency:go-offline 7 | 8 | # Copy sources and build JAR 9 | COPY . . 10 | RUN mvn -o package 11 | 12 | FROM openjdk:11-jre AS runtime 13 | WORKDIR /app 14 | COPY --from=build /app/target/java-reactor-netty-1.0-SNAPSHOT-jar-with-dependencies.jar . 15 | ENTRYPOINT ["java", "-jar", "java-reactor-netty-1.0-SNAPSHOT-jar-with-dependencies.jar"] 16 | -------------------------------------------------------------------------------- /java-reactor-netty/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-java-reactor-netty . 2 | -------------------------------------------------------------------------------- /java-reactor-netty/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-java-reactor-netty . 4 | -------------------------------------------------------------------------------- /java-reactor-netty/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | com.mycompany.app 8 | java-reactor-netty 9 | 1.0-SNAPSHOT 10 | 11 | java-reactor-netty 12 | 13 | http://www.example.com 14 | 15 | 16 | UTF-8 17 | 1.8 18 | 1.8 19 | 20 | 21 | 22 | 23 | 24 | io.projectreactor 25 | reactor-bom 26 | Dysprosium-SR5 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | 35 | io.projectreactor.netty 36 | reactor-netty 37 | 38 | 39 | 40 | 41 | 42 | 43 | 48 | 49 | maven-dependency-plugin 50 | 3.1.1 51 | 52 | 53 | 54 | 55 | 56 | org.apache.maven.plugins 57 | maven-assembly-plugin 58 | 59 | 60 | package 61 | 62 | single 63 | 64 | 65 | 66 | 67 | 68 | com.mycompany.app.App 69 | 70 | 71 | 72 | 73 | jar-with-dependencies 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /java-reactor-netty/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-java-reactor-netty %* 2 | -------------------------------------------------------------------------------- /java-reactor-netty/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-java-reactor-netty "$@" 4 | -------------------------------------------------------------------------------- /java-reactor-netty/src/main/java/com/mycompany/app/App.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.app; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import reactor.core.publisher.Flux; 6 | import reactor.core.publisher.Mono; 7 | import reactor.core.scheduler.Schedulers; 8 | import reactor.netty.http.client.HttpClient; 9 | 10 | public class App { 11 | private static final HttpClient _httpClient = HttpClient.create(); 12 | private static AtomicInteger _completedRequests = new AtomicInteger(0); 13 | 14 | public static void main(String[] args) { 15 | if (args.length == 0) { 16 | System.out.println("Usage: app "); 17 | return; 18 | } 19 | 20 | String url = args[0]; 21 | int parallel = args.length >= 2 ? Integer.parseInt(args[1]) : 64; 22 | int warmup = args.length >= 3 ? Integer.parseInt(args[2]) : 30; 23 | int duration = args.length >= 4 ? Integer.parseInt(args[3]) : 10; 24 | 25 | System.out.println("=== Parameters ==="); 26 | System.out.printf("Url: %s%n", url); 27 | System.out.printf("Parallel: %s%n", parallel); 28 | System.out.printf("Warmup: %s%n", warmup); 29 | System.out.printf("Duration: %s%n", duration); 30 | System.out.println(); 31 | 32 | Flux.range(0, parallel).parallel().runOn(Schedulers.boundedElastic()).flatMap(i -> ExecuteRequests(url)).subscribe(); 33 | 34 | CollectResults("Warmup", warmup); 35 | CollectResults("Test", duration); 36 | } 37 | 38 | private static Mono ExecuteRequests(String url) { 39 | return Flux.just(1).repeat() 40 | .flatMap(i -> _httpClient.get().uri(url).responseContent().aggregate().asString().then(Mono.just(1)), 1) 41 | .doOnNext(v -> { 42 | _completedRequests.incrementAndGet(); 43 | }).then(); 44 | } 45 | 46 | private static void CollectResults(String title, int duration) { 47 | System.out.printf("=== %s ===%n", title); 48 | 49 | long startNanoTime = System.nanoTime(); 50 | _completedRequests.set(0); 51 | 52 | try { 53 | Thread.sleep(duration * 1000); 54 | } 55 | catch (Exception e) { 56 | } 57 | 58 | PrintResults(_completedRequests.get(), (System.nanoTime() - startNanoTime)); 59 | } 60 | 61 | private static void PrintResults(int completedRequests, long elapsedNanoTime) { 62 | double elapsedSeconds = elapsedNanoTime / 1000000000; 63 | double requestsPerSecond = completedRequests / elapsedSeconds; 64 | 65 | System.out.printf("Completed %d requests in %.2f seconds (%.0f req/s)%n", 66 | completedRequests, elapsedSeconds, requestsPerSecond); 67 | System.out.println(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /js-axios/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | 9 | node_modules 10 | npm-debug.log 11 | -------------------------------------------------------------------------------- /js-axios/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Microbundle cache 60 | .rpt2_cache/ 61 | .rts2_cache_cjs/ 62 | .rts2_cache_es/ 63 | .rts2_cache_umd/ 64 | 65 | # Optional REPL history 66 | .node_repl_history 67 | 68 | # Output of 'npm pack' 69 | *.tgz 70 | 71 | # Yarn Integrity file 72 | .yarn-integrity 73 | 74 | # dotenv environment variables file 75 | .env 76 | .env.test 77 | 78 | # parcel-bundler cache (https://parceljs.org/) 79 | .cache 80 | 81 | # Next.js build output 82 | .next 83 | 84 | # Nuxt.js build / generate output 85 | .nuxt 86 | dist 87 | 88 | # Gatsby files 89 | .cache/ 90 | # Comment in the public line in if your project uses Gatsby and not Next.js 91 | # https://nextjs.org/blog/next-9-1#public-directory-support 92 | # public 93 | 94 | # vuepress build output 95 | .vuepress/dist 96 | 97 | # Serverless directories 98 | .serverless/ 99 | 100 | # FuseBox cache 101 | .fusebox/ 102 | 103 | # DynamoDB Local files 104 | .dynamodb/ 105 | 106 | # TernJS port file 107 | .tern-port 108 | 109 | # Stores VSCode versions used for testing VSCode extensions 110 | .vscode-test -------------------------------------------------------------------------------- /js-axios/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12 2 | 3 | WORKDIR /app 4 | 5 | COPY package*.json ./ 6 | RUN npm ci --only=production 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["node", "app.js"] 11 | -------------------------------------------------------------------------------- /js-axios/app.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios'); 2 | const http = require('http'); 3 | 4 | let completedRequests = 0; 5 | 6 | async function executeRequests(url) { 7 | while (true) { 8 | const response = await axios.get(url); 9 | completedRequests++; 10 | } 11 | } 12 | 13 | function printResults(requests, duration) { 14 | const requestsPerSecond = requests / duration; 15 | console.log(`Completed ${requests} requests in ${duration.toFixed(2)} seconds (${requestsPerSecond.toFixed(2)} req/s)`); 16 | console.log(); 17 | } 18 | 19 | function sleep(duration) { 20 | return new Promise(resolve => setTimeout(resolve, duration * 1000)); 21 | } 22 | 23 | async function collectResults(title, duration) { 24 | console.log(`=== ${title} ===`); 25 | 26 | const startNs = process.hrtime.bigint(); 27 | completedRequests = 0; 28 | await sleep(duration); 29 | const endNs = process.hrtime.bigint(); 30 | 31 | printResults(completedRequests, Number(endNs - startNs) / 1000000000); 32 | } 33 | 34 | async function main() { 35 | if (process.argv.length <= 2) { 36 | console.log('Usage: app '); 37 | return; 38 | } 39 | 40 | const url = process.argv[2]; 41 | const parallel = process.argv.length >= 4 ? parseInt(process.argv[3]) : 64; 42 | const warmup = process.argv.length >= 5 ? parseInt(process.argv[4]) : 10; 43 | const duration = process.argv.length >= 6 ? parseInt(process.argv[5]) : 10; 44 | 45 | console.log('=== Parameters ==='); 46 | console.log(`Url: ${url}`); 47 | console.log(`Parallel: ${parallel}`); 48 | console.log(`Warmup: ${warmup}`); 49 | console.log(`Duration: ${duration}`); 50 | console.log() 51 | 52 | axios.defaults.httpAgent = new http.Agent({ keepAlive: true }); 53 | 54 | const promises = []; 55 | 56 | for (let i = 0; i < parallel; i++) { 57 | promises[i] = executeRequests(url); 58 | } 59 | 60 | await collectResults('Warmup', warmup); 61 | await collectResults('Test', duration); 62 | 63 | process.exit(); 64 | } 65 | 66 | main().then().catch(console.error); 67 | -------------------------------------------------------------------------------- /js-axios/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-js-axios . 2 | -------------------------------------------------------------------------------- /js-axios/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-js-axios . 4 | -------------------------------------------------------------------------------- /js-axios/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-axios", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "axios": { 8 | "version": "0.19.2", 9 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", 10 | "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", 11 | "requires": { 12 | "follow-redirects": "1.5.10" 13 | } 14 | }, 15 | "debug": { 16 | "version": "3.1.0", 17 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 18 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 19 | "requires": { 20 | "ms": "2.0.0" 21 | } 22 | }, 23 | "follow-redirects": { 24 | "version": "1.5.10", 25 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", 26 | "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", 27 | "requires": { 28 | "debug": "=3.1.0" 29 | } 30 | }, 31 | "ms": { 32 | "version": "2.0.0", 33 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 34 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /js-axios/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-axios", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "axios": "^0.19.2" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /js-axios/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-js-axios %* 2 | -------------------------------------------------------------------------------- /js-axios/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-js-axios "$@" 4 | -------------------------------------------------------------------------------- /js-azure-core-http/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | 9 | node_modules 10 | npm-debug.log 11 | -------------------------------------------------------------------------------- /js-azure-core-http/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Microbundle cache 60 | .rpt2_cache/ 61 | .rts2_cache_cjs/ 62 | .rts2_cache_es/ 63 | .rts2_cache_umd/ 64 | 65 | # Optional REPL history 66 | .node_repl_history 67 | 68 | # Output of 'npm pack' 69 | *.tgz 70 | 71 | # Yarn Integrity file 72 | .yarn-integrity 73 | 74 | # dotenv environment variables file 75 | .env 76 | .env.test 77 | 78 | # parcel-bundler cache (https://parceljs.org/) 79 | .cache 80 | 81 | # Next.js build output 82 | .next 83 | 84 | # Nuxt.js build / generate output 85 | .nuxt 86 | dist 87 | 88 | # Gatsby files 89 | .cache/ 90 | # Comment in the public line in if your project uses Gatsby and not Next.js 91 | # https://nextjs.org/blog/next-9-1#public-directory-support 92 | # public 93 | 94 | # vuepress build output 95 | .vuepress/dist 96 | 97 | # Serverless directories 98 | .serverless/ 99 | 100 | # FuseBox cache 101 | .fusebox/ 102 | 103 | # DynamoDB Local files 104 | .dynamodb/ 105 | 106 | # TernJS port file 107 | .tern-port 108 | 109 | # Stores VSCode versions used for testing VSCode extensions 110 | .vscode-test -------------------------------------------------------------------------------- /js-azure-core-http/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12 2 | 3 | WORKDIR /app 4 | 5 | COPY package*.json ./ 6 | RUN npm ci --only=production 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["node", "app.js"] 11 | -------------------------------------------------------------------------------- /js-azure-core-http/app.js: -------------------------------------------------------------------------------- 1 | const { ServiceClient, createPipelineFromOptions, Serializer } = require('@azure/core-http'); 2 | 3 | const pipeline = createPipelineFromOptions({ 4 | deserializationOptions: { 5 | expectedContentTypes: { 6 | json: ["application/json", "text/json"] 7 | } 8 | } 9 | }); 10 | 11 | const client = new ServiceClient(undefined, pipeline); 12 | 13 | let completedRequests = 0; 14 | 15 | async function executeRequests(operationArguments, operationSpec) { 16 | while (true) { 17 | await client.sendOperationRequest(operationArguments, operationSpec); 18 | completedRequests++; 19 | } 20 | } 21 | 22 | function printResults(requests, duration) { 23 | const requestsPerSecond = requests / duration; 24 | console.log(`Completed ${requests} requests in ${duration.toFixed(2)} seconds (${requestsPerSecond.toFixed(2)} req/s)`); 25 | console.log(); 26 | } 27 | 28 | function sleep(duration) { 29 | return new Promise(resolve => setTimeout(resolve, duration * 1000)); 30 | } 31 | 32 | async function collectResults(title, duration) { 33 | console.log(`=== ${title} ===`); 34 | 35 | const startNs = process.hrtime.bigint(); 36 | completedRequests = 0; 37 | await sleep(duration); 38 | const endNs = process.hrtime.bigint(); 39 | 40 | printResults(completedRequests, Number(endNs - startNs) / 1000000000); 41 | } 42 | 43 | async function main() { 44 | if (process.argv.length <= 2) { 45 | console.log('Usage: app '); 46 | return; 47 | } 48 | 49 | const url = process.argv[2]; 50 | const parallel = process.argv.length >= 4 ? parseInt(process.argv[3]) : 64; 51 | const warmup = process.argv.length >= 5 ? parseInt(process.argv[4]) : 10; 52 | const duration = process.argv.length >= 6 ? parseInt(process.argv[5]) : 10; 53 | 54 | console.log('=== Parameters ==='); 55 | console.log(`Url: ${url}`); 56 | console.log(`Parallel: ${parallel}`); 57 | console.log(`Warmup: ${warmup}`); 58 | console.log(`Duration: ${duration}`); 59 | console.log() 60 | 61 | const operationArguments = {}; 62 | const operationSpec = { 63 | httpMethod: "GET", 64 | baseUrl: url, 65 | serializer: new Serializer(), 66 | responses: {} 67 | }; 68 | 69 | const promises = []; 70 | 71 | for (let i = 0; i < parallel; i++) { 72 | promises[i] = executeRequests(operationArguments, operationSpec); 73 | } 74 | 75 | await collectResults('Warmup', warmup); 76 | await collectResults('Test', duration); 77 | 78 | process.exit(); 79 | } 80 | 81 | main().then().catch(console.error); 82 | -------------------------------------------------------------------------------- /js-azure-core-http/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-js-azure-core-http . 2 | -------------------------------------------------------------------------------- /js-azure-core-http/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-js-azure-core-http . 4 | -------------------------------------------------------------------------------- /js-azure-core-http/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-node-fetch", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@azure/abort-controller": { 8 | "version": "1.0.1", 9 | "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.1.tgz", 10 | "integrity": "sha512-wP2Jw6uPp8DEDy0n4KNidvwzDjyVV2xnycEIq7nPzj1rHyb/r+t3OPeNT1INZePP2wy5ZqlwyuyOMTi0ePyY1A==", 11 | "requires": { 12 | "tslib": "^1.9.3" 13 | } 14 | }, 15 | "@azure/core-auth": { 16 | "version": "1.0.2", 17 | "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.0.2.tgz", 18 | "integrity": "sha512-zhPJObdrhz2ymIqGL1x8i3meEuaLz0UPjH9mOq9RGOlJB2Pb6K6xPtkHbRsfElgoO9USR4hH2XU5pLa4/JHHIw==", 19 | "requires": { 20 | "@azure/abort-controller": "^1.0.0", 21 | "@azure/core-tracing": "1.0.0-preview.7", 22 | "@opentelemetry/types": "^0.2.0", 23 | "tslib": "^1.9.3" 24 | } 25 | }, 26 | "@azure/core-http": { 27 | "version": "1.0.3", 28 | "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-1.0.3.tgz", 29 | "integrity": "sha512-hmsalo2i1noF5LMwNBNymJnf210ha7Rh6x+BQBBcb+wUZI5hVGRbaRgHzqpJiH8FmfJrDuKZI+S7i2rILUBJTg==", 30 | "requires": { 31 | "@azure/abort-controller": "^1.0.0", 32 | "@azure/core-auth": "^1.0.0", 33 | "@azure/core-tracing": "1.0.0-preview.7", 34 | "@azure/logger": "^1.0.0", 35 | "@opentelemetry/types": "^0.2.0", 36 | "@types/node-fetch": "^2.5.0", 37 | "@types/tunnel": "^0.0.1", 38 | "form-data": "^3.0.0", 39 | "node-fetch": "^2.6.0", 40 | "process": "^0.11.10", 41 | "tough-cookie": "^3.0.1", 42 | "tslib": "^1.10.0", 43 | "tunnel": "^0.0.6", 44 | "uuid": "^3.3.2", 45 | "xml2js": "^0.4.19" 46 | } 47 | }, 48 | "@azure/core-tracing": { 49 | "version": "1.0.0-preview.7", 50 | "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.0.0-preview.7.tgz", 51 | "integrity": "sha512-pkFCw6OiJrpR+aH1VQe6DYm3fK2KWCC5Jf3m/Pv1RxF08M1Xm08RCyQ5Qe0YyW5L16yYT2nnV48krVhYZ6SGFA==", 52 | "requires": { 53 | "@opencensus/web-types": "0.0.7", 54 | "@opentelemetry/types": "^0.2.0", 55 | "tslib": "^1.9.3" 56 | } 57 | }, 58 | "@azure/logger": { 59 | "version": "1.0.0", 60 | "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.0.tgz", 61 | "integrity": "sha512-g2qLDgvmhyIxR3JVS8N67CyIOeFRKQlX/llxYJQr1OSGQqM3HTpVP8MjmjcEKbL/OIt2N9C9UFaNQuKOw1laOA==", 62 | "requires": { 63 | "tslib": "^1.9.3" 64 | } 65 | }, 66 | "@opencensus/web-types": { 67 | "version": "0.0.7", 68 | "resolved": "https://registry.npmjs.org/@opencensus/web-types/-/web-types-0.0.7.tgz", 69 | "integrity": "sha512-xB+w7ZDAu3YBzqH44rCmG9/RlrOmFuDPt/bpf17eJr8eZSrLt7nc7LnWdxM9Mmoj/YKMHpxRg28txu3TcpiL+g==" 70 | }, 71 | "@opentelemetry/types": { 72 | "version": "0.2.0", 73 | "resolved": "https://registry.npmjs.org/@opentelemetry/types/-/types-0.2.0.tgz", 74 | "integrity": "sha512-GtwNB6BNDdsIPAYEdpp3JnOGO/3AJxjPvny53s3HERBdXSJTGQw8IRhiaTEX0b3w9P8+FwFZde4k+qkjn67aVw==" 75 | }, 76 | "@types/node": { 77 | "version": "13.7.4", 78 | "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.4.tgz", 79 | "integrity": "sha512-oVeL12C6gQS/GAExndigSaLxTrKpQPxewx9bOcwfvJiJge4rr7wNaph4J+ns5hrmIV2as5qxqN8YKthn9qh0jw==" 80 | }, 81 | "@types/node-fetch": { 82 | "version": "2.5.5", 83 | "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.5.tgz", 84 | "integrity": "sha512-IWwjsyYjGw+em3xTvWVQi5MgYKbRs0du57klfTaZkv/B24AEQ/p/IopNeqIYNy3EsfHOpg8ieQSDomPcsYMHpA==", 85 | "requires": { 86 | "@types/node": "*", 87 | "form-data": "^3.0.0" 88 | } 89 | }, 90 | "@types/tunnel": { 91 | "version": "0.0.1", 92 | "resolved": "https://registry.npmjs.org/@types/tunnel/-/tunnel-0.0.1.tgz", 93 | "integrity": "sha512-AOqu6bQu5MSWwYvehMXLukFHnupHrpZ8nvgae5Ggie9UwzDR1CCwoXgSSWNZJuyOlCdfdsWMA5F2LlmvyoTv8A==", 94 | "requires": { 95 | "@types/node": "*" 96 | } 97 | }, 98 | "asynckit": { 99 | "version": "0.4.0", 100 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 101 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 102 | }, 103 | "combined-stream": { 104 | "version": "1.0.8", 105 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 106 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 107 | "requires": { 108 | "delayed-stream": "~1.0.0" 109 | } 110 | }, 111 | "delayed-stream": { 112 | "version": "1.0.0", 113 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 114 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 115 | }, 116 | "form-data": { 117 | "version": "3.0.0", 118 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", 119 | "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", 120 | "requires": { 121 | "asynckit": "^0.4.0", 122 | "combined-stream": "^1.0.8", 123 | "mime-types": "^2.1.12" 124 | } 125 | }, 126 | "ip-regex": { 127 | "version": "2.1.0", 128 | "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", 129 | "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=" 130 | }, 131 | "mime-db": { 132 | "version": "1.43.0", 133 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", 134 | "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" 135 | }, 136 | "mime-types": { 137 | "version": "2.1.26", 138 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", 139 | "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", 140 | "requires": { 141 | "mime-db": "1.43.0" 142 | } 143 | }, 144 | "node-fetch": { 145 | "version": "2.6.1", 146 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 147 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" 148 | }, 149 | "process": { 150 | "version": "0.11.10", 151 | "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", 152 | "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" 153 | }, 154 | "psl": { 155 | "version": "1.7.0", 156 | "resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz", 157 | "integrity": "sha512-5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ==" 158 | }, 159 | "punycode": { 160 | "version": "2.1.1", 161 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 162 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" 163 | }, 164 | "sax": { 165 | "version": "1.2.4", 166 | "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", 167 | "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" 168 | }, 169 | "tough-cookie": { 170 | "version": "3.0.1", 171 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", 172 | "integrity": "sha512-yQyJ0u4pZsv9D4clxO69OEjLWYw+jbgspjTue4lTQZLfV0c5l1VmK2y1JK8E9ahdpltPOaAThPcp5nKPUgSnsg==", 173 | "requires": { 174 | "ip-regex": "^2.1.0", 175 | "psl": "^1.1.28", 176 | "punycode": "^2.1.1" 177 | } 178 | }, 179 | "tslib": { 180 | "version": "1.11.0", 181 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.0.tgz", 182 | "integrity": "sha512-BmndXUtiTn/VDDrJzQE7Mm22Ix3PxgLltW9bSNLoeCY31gnG2OPx0QqJnuc9oMIKioYrz487i6K9o4Pdn0j+Kg==" 183 | }, 184 | "tunnel": { 185 | "version": "0.0.6", 186 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 187 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" 188 | }, 189 | "uuid": { 190 | "version": "3.4.0", 191 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", 192 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" 193 | }, 194 | "xml2js": { 195 | "version": "0.4.23", 196 | "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", 197 | "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", 198 | "requires": { 199 | "sax": ">=0.6.0", 200 | "xmlbuilder": "~11.0.0" 201 | } 202 | }, 203 | "xmlbuilder": { 204 | "version": "11.0.1", 205 | "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", 206 | "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" 207 | } 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /js-azure-core-http/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-node-fetch", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@azure/core-http": "^1.0.3" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /js-azure-core-http/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-js-azure-core-http %* 2 | -------------------------------------------------------------------------------- /js-azure-core-http/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-js-azure-core-http "$@" 4 | -------------------------------------------------------------------------------- /js-http/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | 9 | node_modules 10 | npm-debug.log 11 | -------------------------------------------------------------------------------- /js-http/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Microbundle cache 60 | .rpt2_cache/ 61 | .rts2_cache_cjs/ 62 | .rts2_cache_es/ 63 | .rts2_cache_umd/ 64 | 65 | # Optional REPL history 66 | .node_repl_history 67 | 68 | # Output of 'npm pack' 69 | *.tgz 70 | 71 | # Yarn Integrity file 72 | .yarn-integrity 73 | 74 | # dotenv environment variables file 75 | .env 76 | .env.test 77 | 78 | # parcel-bundler cache (https://parceljs.org/) 79 | .cache 80 | 81 | # Next.js build output 82 | .next 83 | 84 | # Nuxt.js build / generate output 85 | .nuxt 86 | dist 87 | 88 | # Gatsby files 89 | .cache/ 90 | # Comment in the public line in if your project uses Gatsby and not Next.js 91 | # https://nextjs.org/blog/next-9-1#public-directory-support 92 | # public 93 | 94 | # vuepress build output 95 | .vuepress/dist 96 | 97 | # Serverless directories 98 | .serverless/ 99 | 100 | # FuseBox cache 101 | .fusebox/ 102 | 103 | # DynamoDB Local files 104 | .dynamodb/ 105 | 106 | # TernJS port file 107 | .tern-port 108 | 109 | # Stores VSCode versions used for testing VSCode extensions 110 | .vscode-test -------------------------------------------------------------------------------- /js-http/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12 2 | 3 | WORKDIR /app 4 | 5 | COPY package*.json ./ 6 | RUN npm ci --only=production 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["node", "app.js"] 11 | -------------------------------------------------------------------------------- /js-http/app.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | 3 | let completedRequests = 0; 4 | 5 | function executeRequests(url, options) { 6 | http.get(url, options, (res) => { 7 | res.on('data', (chunk) => { }); 8 | 9 | res.on('end', () => { 10 | completedRequests++; 11 | executeRequests(url, options); 12 | }); 13 | }); 14 | } 15 | 16 | function printResults(requests, duration) { 17 | const requestsPerSecond = requests / duration; 18 | console.log(`Completed ${requests} requests in ${duration.toFixed(2)} seconds (${requestsPerSecond.toFixed(2)} req/s)`); 19 | console.log(); 20 | } 21 | 22 | function sleep(duration) { 23 | return new Promise(resolve => setTimeout(resolve, duration * 1000)); 24 | } 25 | 26 | async function collectResults(title, duration) { 27 | console.log(`=== ${title} ===`); 28 | 29 | const startNs = process.hrtime.bigint(); 30 | completedRequests = 0; 31 | await sleep(duration); 32 | const endNs = process.hrtime.bigint(); 33 | 34 | printResults(completedRequests, Number(endNs - startNs) / 1000000000); 35 | } 36 | 37 | async function main() { 38 | if (process.argv.length <= 2) { 39 | console.log('Usage: app '); 40 | return; 41 | } 42 | 43 | const url = process.argv[2]; 44 | const parallel = process.argv.length >= 4 ? parseInt(process.argv[3]) : 64; 45 | const warmup = process.argv.length >= 5 ? parseInt(process.argv[4]) : 10; 46 | const duration = process.argv.length >= 6 ? parseInt(process.argv[5]) : 10; 47 | 48 | console.log('=== Parameters ==='); 49 | console.log(`Url: ${url}`); 50 | console.log(`Parallel: ${parallel}`); 51 | console.log(`Warmup: ${warmup}`); 52 | console.log(`Duration: ${duration}`); 53 | console.log() 54 | 55 | const options = { 56 | agent: new http.Agent({ keepAlive: true }) 57 | }; 58 | 59 | for (let i = 0; i < parallel; i++) { 60 | executeRequests(url, options); 61 | } 62 | 63 | await collectResults('Warmup', warmup); 64 | await collectResults('Test', duration); 65 | 66 | process.exit(); 67 | } 68 | 69 | main().then().catch(console.error); 70 | -------------------------------------------------------------------------------- /js-http/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-js-http . 2 | -------------------------------------------------------------------------------- /js-http/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-js-http . 4 | -------------------------------------------------------------------------------- /js-http/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-http", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /js-http/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-http", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC" 11 | } 12 | -------------------------------------------------------------------------------- /js-http/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-js-http %* 2 | -------------------------------------------------------------------------------- /js-http/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-js-http "$@" 4 | -------------------------------------------------------------------------------- /js-node-fetch/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | 9 | node_modules 10 | npm-debug.log 11 | -------------------------------------------------------------------------------- /js-node-fetch/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Microbundle cache 60 | .rpt2_cache/ 61 | .rts2_cache_cjs/ 62 | .rts2_cache_es/ 63 | .rts2_cache_umd/ 64 | 65 | # Optional REPL history 66 | .node_repl_history 67 | 68 | # Output of 'npm pack' 69 | *.tgz 70 | 71 | # Yarn Integrity file 72 | .yarn-integrity 73 | 74 | # dotenv environment variables file 75 | .env 76 | .env.test 77 | 78 | # parcel-bundler cache (https://parceljs.org/) 79 | .cache 80 | 81 | # Next.js build output 82 | .next 83 | 84 | # Nuxt.js build / generate output 85 | .nuxt 86 | dist 87 | 88 | # Gatsby files 89 | .cache/ 90 | # Comment in the public line in if your project uses Gatsby and not Next.js 91 | # https://nextjs.org/blog/next-9-1#public-directory-support 92 | # public 93 | 94 | # vuepress build output 95 | .vuepress/dist 96 | 97 | # Serverless directories 98 | .serverless/ 99 | 100 | # FuseBox cache 101 | .fusebox/ 102 | 103 | # DynamoDB Local files 104 | .dynamodb/ 105 | 106 | # TernJS port file 107 | .tern-port 108 | 109 | # Stores VSCode versions used for testing VSCode extensions 110 | .vscode-test -------------------------------------------------------------------------------- /js-node-fetch/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12 2 | 3 | WORKDIR /app 4 | 5 | COPY package*.json ./ 6 | RUN npm ci --only=production 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["node", "app.js"] 11 | -------------------------------------------------------------------------------- /js-node-fetch/app.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | const http = require('http'); 3 | 4 | let completedRequests = 0; 5 | 6 | async function executeRequests(url, options) { 7 | while (true) { 8 | const response = await fetch(url, options); 9 | await response.text(); 10 | completedRequests++; 11 | } 12 | } 13 | 14 | function printResults(requests, duration) { 15 | const requestsPerSecond = requests / duration; 16 | console.log(`Completed ${requests} requests in ${duration.toFixed(2)} seconds (${requestsPerSecond.toFixed(2)} req/s)`); 17 | console.log(); 18 | } 19 | 20 | function sleep(duration) { 21 | return new Promise(resolve => setTimeout(resolve, duration * 1000)); 22 | } 23 | 24 | async function collectResults(title, duration) { 25 | console.log(`=== ${title} ===`); 26 | 27 | const startNs = process.hrtime.bigint(); 28 | completedRequests = 0; 29 | await sleep(duration); 30 | const endNs = process.hrtime.bigint(); 31 | 32 | printResults(completedRequests, Number(endNs - startNs) / 1000000000); 33 | } 34 | 35 | async function main() { 36 | if (process.argv.length <= 2) { 37 | console.log('Usage: app '); 38 | return; 39 | } 40 | 41 | const url = process.argv[2]; 42 | const parallel = process.argv.length >= 4 ? parseInt(process.argv[3]) : 64; 43 | const warmup = process.argv.length >= 5 ? parseInt(process.argv[4]) : 10; 44 | const duration = process.argv.length >= 6 ? parseInt(process.argv[5]) : 10; 45 | 46 | console.log('=== Parameters ==='); 47 | console.log(`Url: ${url}`); 48 | console.log(`Parallel: ${parallel}`); 49 | console.log(`Warmup: ${warmup}`); 50 | console.log(`Duration: ${duration}`); 51 | console.log() 52 | 53 | const options = { 54 | agent: new http.Agent({ keepAlive: true }) 55 | }; 56 | 57 | const promises = []; 58 | 59 | for (let i = 0; i < parallel; i++) { 60 | promises[i] = executeRequests(url, options); 61 | } 62 | 63 | await collectResults('Warmup', warmup); 64 | await collectResults('Test', duration); 65 | 66 | process.exit(); 67 | } 68 | 69 | main().then().catch(console.error); 70 | -------------------------------------------------------------------------------- /js-node-fetch/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-js-node-fetch . 2 | -------------------------------------------------------------------------------- /js-node-fetch/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-js-node-fetch . 4 | -------------------------------------------------------------------------------- /js-node-fetch/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-node-fetch", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "node-fetch": { 8 | "version": "2.6.1", 9 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 10 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /js-node-fetch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-node-fetch", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "node-fetch": "^2.6.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /js-node-fetch/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-js-node-fetch %* 2 | -------------------------------------------------------------------------------- /js-node-fetch/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-js-node-fetch "$@" 4 | -------------------------------------------------------------------------------- /js-sockets/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | 9 | node_modules 10 | npm-debug.log 11 | -------------------------------------------------------------------------------- /js-sockets/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Microbundle cache 60 | .rpt2_cache/ 61 | .rts2_cache_cjs/ 62 | .rts2_cache_es/ 63 | .rts2_cache_umd/ 64 | 65 | # Optional REPL history 66 | .node_repl_history 67 | 68 | # Output of 'npm pack' 69 | *.tgz 70 | 71 | # Yarn Integrity file 72 | .yarn-integrity 73 | 74 | # dotenv environment variables file 75 | .env 76 | .env.test 77 | 78 | # parcel-bundler cache (https://parceljs.org/) 79 | .cache 80 | 81 | # Next.js build output 82 | .next 83 | 84 | # Nuxt.js build / generate output 85 | .nuxt 86 | dist 87 | 88 | # Gatsby files 89 | .cache/ 90 | # Comment in the public line in if your project uses Gatsby and not Next.js 91 | # https://nextjs.org/blog/next-9-1#public-directory-support 92 | # public 93 | 94 | # vuepress build output 95 | .vuepress/dist 96 | 97 | # Serverless directories 98 | .serverless/ 99 | 100 | # FuseBox cache 101 | .fusebox/ 102 | 103 | # DynamoDB Local files 104 | .dynamodb/ 105 | 106 | # TernJS port file 107 | .tern-port 108 | 109 | # Stores VSCode versions used for testing VSCode extensions 110 | .vscode-test -------------------------------------------------------------------------------- /js-sockets/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12 2 | 3 | WORKDIR /app 4 | 5 | COPY package*.json ./ 6 | RUN npm ci --only=production 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["node", "app.js"] 11 | -------------------------------------------------------------------------------- /js-sockets/app.js: -------------------------------------------------------------------------------- 1 | const net = require('net'); 2 | const url = require('url'); 3 | 4 | let completedRequests = 0; 5 | 6 | function executeRequests(host, port, messageBytes) { 7 | const socket = new net.Socket(); 8 | 9 | socket.connect(port, host, function() { 10 | socket.write(messageBytes); 11 | }); 12 | 13 | socket.on('data', function(data) { 14 | completedRequests++; 15 | socket.write(messageBytes); 16 | }); 17 | } 18 | 19 | function printResults(requests, duration) { 20 | const requestsPerSecond = requests / duration; 21 | console.log(`Completed ${requests} requests in ${duration.toFixed(2)} seconds (${requestsPerSecond.toFixed(2)} req/s)`); 22 | console.log(); 23 | } 24 | 25 | function sleep(duration) { 26 | return new Promise(resolve => setTimeout(resolve, duration * 1000)); 27 | } 28 | 29 | async function collectResults(title, duration) { 30 | console.log(`=== ${title} ===`); 31 | 32 | const startNs = process.hrtime.bigint(); 33 | completedRequests = 0; 34 | await sleep(duration); 35 | const endNs = process.hrtime.bigint(); 36 | 37 | printResults(completedRequests, Number(endNs - startNs) / 1000000000); 38 | } 39 | 40 | async function main() { 41 | if (process.argv.length <= 2) { 42 | console.log('Usage: app '); 43 | return; 44 | } 45 | 46 | const urlString = process.argv[2]; 47 | const parallel = process.argv.length >= 4 ? parseInt(process.argv[3]) : 128; 48 | const warmup = process.argv.length >= 5 ? parseInt(process.argv[4]) : 10; 49 | const duration = process.argv.length >= 6 ? parseInt(process.argv[5]) : 10; 50 | 51 | console.log('=== Parameters ==='); 52 | console.log(`Url: ${urlString}`); 53 | console.log(`Parallel: ${parallel}`); 54 | console.log(`Warmup: ${warmup}`); 55 | console.log(`Duration: ${duration}`); 56 | console.log() 57 | 58 | const urlObject = url.parse(urlString); 59 | const host = urlObject.hostname; 60 | const port = urlObject.port; 61 | const path = urlObject.path || '/'; 62 | 63 | const message = `GET ${path} HTTP/1.1\r\nHost: ${host}:${port}\r\n\r\n`; 64 | const messageBytes = Buffer.from(message); 65 | 66 | for (let i = 0; i < parallel; i++) { 67 | executeRequests(host, port, messageBytes); 68 | } 69 | 70 | await collectResults('Warmup', warmup); 71 | await collectResults('Test', duration); 72 | 73 | process.exit(); 74 | } 75 | 76 | main().then().catch(console.error); 77 | -------------------------------------------------------------------------------- /js-sockets/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-js-sockets . 2 | -------------------------------------------------------------------------------- /js-sockets/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-js-sockets . 4 | -------------------------------------------------------------------------------- /js-sockets/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-sockets", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /js-sockets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-sockets", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC" 11 | } 12 | -------------------------------------------------------------------------------- /js-sockets/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-js-sockets %* 2 | -------------------------------------------------------------------------------- /js-sockets/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-js-sockets "$@" 4 | -------------------------------------------------------------------------------- /net-http-client-put/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | -------------------------------------------------------------------------------- /net-http-client-put/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Coverlet is a free, cross platform Code Coverage Tool 141 | coverage*[.json, .xml, .info] 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | -------------------------------------------------------------------------------- /net-http-client-put/Dockerfile: -------------------------------------------------------------------------------- 1 | # https://hub.docker.com/_/microsoft-dotnet-core 2 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1.302 AS build 3 | WORKDIR /source 4 | 5 | # copy csproj and restore as distinct layers 6 | COPY *.csproj . 7 | RUN dotnet restore 8 | 9 | # copy and publish app and libraries 10 | COPY . . 11 | RUN dotnet publish -c release -o /app --no-restore -f netcoreapp3.1 12 | 13 | # final stage/image 14 | FROM mcr.microsoft.com/dotnet/core/runtime:3.1.6 15 | WORKDIR /app 16 | COPY --from=build /app ./ 17 | ENTRYPOINT ["./app"] 18 | -------------------------------------------------------------------------------- /net-http-client-put/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Net.Http; 4 | using System.Runtime; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace App 9 | { 10 | public class Program 11 | { 12 | private static readonly HttpClient _httpClient = new HttpClient(new HttpClientHandler() 13 | { 14 | ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true 15 | }); 16 | 17 | public static async Task Main(string[] args) 18 | { 19 | if (args.Length == 0) 20 | { 21 | Console.WriteLine("Usage: app "); 22 | return; 23 | } 24 | 25 | var url = args[0]; 26 | var size = args.Length >= 2 ? Int32.Parse(args[1]) : 1024; 27 | 28 | Console.WriteLine($"=== Parameters ==="); 29 | Console.WriteLine($"Size: {size}"); 30 | Console.WriteLine($"GCSettings.IsServerGC: {GCSettings.IsServerGC}"); 31 | Console.WriteLine(); 32 | 33 | byte[] payload = new byte[size]; 34 | (new Random(0)).NextBytes(payload); 35 | 36 | var sw = new Stopwatch(); 37 | while(true) { 38 | sw.Restart(); 39 | await ExecuteRequest(url, payload); 40 | sw.Stop(); 41 | 42 | var elapsedSeconds = sw.Elapsed.TotalSeconds; 43 | var mbps = ((size / elapsedSeconds) * 8) / (1024 * 1024); 44 | 45 | Console.WriteLine($"Put {size:N0} bytes in {elapsedSeconds:N2} seconds ({mbps:N2} Mbps)"); 46 | } 47 | } 48 | 49 | private static async Task ExecuteRequest(string url, byte[] payload) 50 | { 51 | using var content = new ByteArrayContent(payload); 52 | using var response = await _httpClient.PutAsync(url, content); 53 | await response.Content.ReadAsStringAsync(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /net-http-client-put/app.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /net-http-client-put/app.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30320.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "app", "app.csproj", "{F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3C862E0E-03D1-4D80-A5A5-ACBCEBC58DAC} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /net-http-client-put/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-net-http-client-put . 2 | -------------------------------------------------------------------------------- /net-http-client-put/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-net-http-client-put . 4 | -------------------------------------------------------------------------------- /net-http-client-put/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-net-http-client-put %* 2 | -------------------------------------------------------------------------------- /net-http-client-put/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-net-http-client-put "$@" 4 | -------------------------------------------------------------------------------- /net-http-client/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | docker-compose.yml 4 | 5 | .gitignore 6 | -------------------------------------------------------------------------------- /net-http-client/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Coverlet is a free, cross platform Code Coverage Tool 141 | coverage*[.json, .xml, .info] 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | -------------------------------------------------------------------------------- /net-http-client/Dockerfile: -------------------------------------------------------------------------------- 1 | # https://hub.docker.com/_/microsoft-dotnet-core 2 | FROM mcr.microsoft.com/dotnet/sdk:5.0.101 AS build 3 | WORKDIR /source 4 | 5 | # copy csproj and restore as distinct layers 6 | COPY *.csproj . 7 | RUN dotnet restore 8 | 9 | # copy and publish app and libraries 10 | COPY . . 11 | RUN dotnet publish -c release -o /app --no-restore 12 | 13 | # final stage/image 14 | FROM mcr.microsoft.com/dotnet/runtime:5.0.1 15 | WORKDIR /app 16 | COPY --from=build /app ./ 17 | ENTRYPOINT ["./app"] 18 | -------------------------------------------------------------------------------- /net-http-client/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Net.Http; 4 | using System.Runtime; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace App 9 | { 10 | public class Program 11 | { 12 | private static readonly HttpClient _httpClient = new HttpClient(); 13 | private static int _completedRequests = 0; 14 | 15 | public static async Task Main(string[] args) 16 | { 17 | if (args.Length == 0) 18 | { 19 | Console.WriteLine("Usage: app "); 20 | return; 21 | } 22 | 23 | var url = args[0]; 24 | var parallel = args.Length >= 2 ? Int32.Parse(args[1]) : 64; 25 | var warmup = args.Length >= 3 ? Int32.Parse(args[2]) : 10; 26 | var duration = args.Length >= 4 ? Int32.Parse(args[3]) : 10; 27 | 28 | Console.WriteLine($"=== Parameters ==="); 29 | Console.WriteLine($"Url: {url}"); 30 | Console.WriteLine($"Parallel: {parallel}"); 31 | Console.WriteLine($"Warmup: {warmup}"); 32 | Console.WriteLine($"Duration: {duration}"); 33 | Console.WriteLine($"GCSettings.IsServerGC: {GCSettings.IsServerGC}"); 34 | Console.WriteLine(); 35 | 36 | var tasks = new Task[parallel]; 37 | for (var i=0; i < parallel; i++) 38 | { 39 | tasks[i] = ExecuteRequests(url); 40 | } 41 | 42 | await CollectResults("Warmup", warmup); 43 | await CollectResults("Test", duration); 44 | } 45 | 46 | private static async Task CollectResults(string title, int duration) { 47 | Console.WriteLine($"=== {title} ==="); 48 | 49 | var stopwatch = Stopwatch.StartNew(); 50 | Interlocked.Exchange(ref _completedRequests, 0); 51 | 52 | await Task.Delay(TimeSpan.FromSeconds(duration)); 53 | 54 | stopwatch.Stop(); 55 | 56 | PrintResults(_completedRequests, stopwatch.Elapsed); 57 | } 58 | 59 | private static void PrintResults(int completedRequests, TimeSpan elapsed) { 60 | var elapsedSeconds = elapsed.TotalSeconds; 61 | var requestsPerSecond = completedRequests / elapsedSeconds; 62 | 63 | Console.WriteLine($"Completed {completedRequests:N0} requests in {elapsedSeconds:N2} seconds ({requestsPerSecond:N0} req/s)"); 64 | Console.WriteLine(); 65 | } 66 | 67 | private static async Task ExecuteRequests(string url) 68 | { 69 | while (true) 70 | { 71 | await ExecuteRequest(url); 72 | Interlocked.Increment(ref _completedRequests); 73 | } 74 | } 75 | 76 | private static async Task ExecuteRequest(string url) 77 | { 78 | await _httpClient.GetStringAsync(url); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /net-http-client/app.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | true 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /net-http-client/app.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30320.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "app", "app.csproj", "{F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {F3BCC2DF-D573-422E-BEAB-E2825F7D07E1}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3C862E0E-03D1-4D80-A5A5-ACBCEBC58DAC} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /net-http-client/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | client: 4 | build: . 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /net-sockets/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | -------------------------------------------------------------------------------- /net-sockets/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Coverlet is a free, cross platform Code Coverage Tool 141 | coverage*[.json, .xml, .info] 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | -------------------------------------------------------------------------------- /net-sockets/Dockerfile: -------------------------------------------------------------------------------- 1 | # https://hub.docker.com/_/microsoft-dotnet-core 2 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1.302 AS build 3 | WORKDIR /source 4 | 5 | # copy csproj and restore as distinct layers 6 | COPY *.csproj . 7 | RUN dotnet restore 8 | 9 | # copy and publish app and libraries 10 | COPY . . 11 | RUN dotnet publish -c release -o /app --no-restore 12 | 13 | # final stage/image 14 | FROM mcr.microsoft.com/dotnet/core/runtime:3.1.6 15 | WORKDIR /app 16 | COPY --from=build /app ./ 17 | ENTRYPOINT ["./app"] 18 | -------------------------------------------------------------------------------- /net-sockets/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Net.Sockets; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace App 9 | { 10 | public class Program 11 | { 12 | private static int _completedRequests = 0; 13 | 14 | public static async Task Main(string[] args) 15 | { 16 | if (args.Length == 0) 17 | { 18 | Console.WriteLine("Usage: app "); 19 | return; 20 | } 21 | 22 | var url = args[0]; 23 | var parallel = args.Length >= 2 ? Int32.Parse(args[1]) : 64; 24 | var warmup = args.Length >= 3 ? Int32.Parse(args[2]) : 10; 25 | var duration = args.Length >= 4 ? Int32.Parse(args[3]) : 10; 26 | 27 | Console.WriteLine($"=== Parameters ==="); 28 | Console.WriteLine($"Url: {url}"); 29 | Console.WriteLine($"Parallel: {parallel}"); 30 | Console.WriteLine($"Warmup: {warmup}"); 31 | Console.WriteLine($"Duration: {duration}"); 32 | Console.WriteLine(); 33 | 34 | var uri = new Uri(url); 35 | var requestBytes = Encoding.UTF8.GetBytes($"GET {uri.PathAndQuery} HTTP/1.1\r\nHost: {uri.Host}:{uri.Port}\r\n\r\n"); 36 | 37 | var tasks = new Task[parallel]; 38 | for (var i=0; i < parallel; i++) 39 | { 40 | tasks[i] = ExecuteRequests(uri.Host, uri.Port, requestBytes); 41 | } 42 | 43 | await CollectResults("Warmup", warmup); 44 | await CollectResults("Test", duration); 45 | } 46 | 47 | private static async Task CollectResults(string title, int duration) { 48 | Console.WriteLine($"=== {title} ==="); 49 | 50 | var stopwatch = Stopwatch.StartNew(); 51 | Interlocked.Exchange(ref _completedRequests, 0); 52 | 53 | await Task.Delay(TimeSpan.FromSeconds(duration)); 54 | 55 | stopwatch.Stop(); 56 | 57 | PrintResults(_completedRequests, stopwatch.Elapsed); 58 | } 59 | 60 | private static void PrintResults(int completedRequests, TimeSpan elapsed) { 61 | var elapsedSeconds = elapsed.TotalSeconds; 62 | var requestsPerSecond = completedRequests / elapsedSeconds; 63 | 64 | Console.WriteLine($"Completed {completedRequests:N0} requests in {elapsedSeconds:N2} seconds ({requestsPerSecond:N0} req/s)"); 65 | Console.WriteLine(); 66 | } 67 | 68 | private static async Task ExecuteRequests(string host, int port, byte[] requestBytes) 69 | { 70 | var buffer = new byte[200]; 71 | 72 | using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp); 73 | await socket.ConnectAsync(host, port); 74 | 75 | while (true) 76 | { 77 | await socket.SendAsync(requestBytes, SocketFlags.None); 78 | await socket.ReceiveAsync(buffer, SocketFlags.None); 79 | Interlocked.Increment(ref _completedRequests); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /net-sockets/app.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /net-sockets/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-net-sockets . 2 | -------------------------------------------------------------------------------- /net-sockets/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-net-sockets . 4 | -------------------------------------------------------------------------------- /net-sockets/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-net-sockets %* 2 | -------------------------------------------------------------------------------- /net-sockets/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-net-sockets "$@" 4 | -------------------------------------------------------------------------------- /python-aiohttp/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | docker-compose.yml 4 | 5 | .gitignore 6 | -------------------------------------------------------------------------------- /python-aiohttp/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | -------------------------------------------------------------------------------- /python-aiohttp/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9.1 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt ./ 6 | RUN pip install --no-cache-dir -r requirements.txt 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["python", "./app.py"] 11 | -------------------------------------------------------------------------------- /python-aiohttp/app.py: -------------------------------------------------------------------------------- 1 | import aiohttp 2 | import asyncio 3 | import sys 4 | import time 5 | 6 | completed_requests = 0 7 | 8 | async def execute_requests(session, url): 9 | global completed_requests 10 | while True: 11 | async with session.get(url) as response: 12 | await response.text() 13 | completed_requests += 1 14 | 15 | def print_results(requests, duration): 16 | requests_per_second = requests / duration 17 | print(f'Completed {requests:,} requests in {duration:.2f} seconds ({requests_per_second:,.0f} req/s)') 18 | print() 19 | 20 | async def collect_results(title, duration): 21 | global completed_requests 22 | print(f'=== {title} ===') 23 | 24 | start = time.perf_counter() 25 | completed_requests = 0 26 | await asyncio.sleep(duration) 27 | end = time.perf_counter() 28 | 29 | print_results(completed_requests, end - start) 30 | 31 | async def main(): 32 | if len(sys.argv) == 1: 33 | print('Usage: app ') 34 | return 35 | 36 | url = sys.argv[1] 37 | parallel = int(sys.argv[2]) if len(sys.argv) >= 3 else 32 38 | warmup = int(sys.argv[3]) if len(sys.argv) >= 4 else 10 39 | duration = int(sys.argv[4]) if len(sys.argv) >= 5 else 10 40 | 41 | print('=== Parameters ===') 42 | print(f'Url: {url}') 43 | print(f'Parallel: {parallel}') 44 | print(f'Warmup: {warmup}') 45 | print(f'Duration: {duration}') 46 | print() 47 | 48 | async with aiohttp.ClientSession() as session: 49 | asyncio.gather(*[execute_requests(session, url) for i in range(parallel)]) 50 | await collect_results('Warmup', warmup) 51 | await collect_results('Test', duration) 52 | 53 | loop = asyncio.get_event_loop() 54 | loop.run_until_complete(main()) 55 | loop.close() 56 | -------------------------------------------------------------------------------- /python-aiohttp/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | client: 4 | build: . 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /python-aiohttp/requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.7.3 2 | -------------------------------------------------------------------------------- /python-http-client-put/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | -------------------------------------------------------------------------------- /python-http-client-put/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8.5 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt ./ 6 | RUN pip install --no-cache-dir -r requirements.txt 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["python", "./app.py"] 11 | -------------------------------------------------------------------------------- /python-http-client-put/app.py: -------------------------------------------------------------------------------- 1 | import os 2 | import ssl 3 | import sys 4 | import time 5 | from urllib.parse import urlparse 6 | import http.client 7 | 8 | class LargeStream: 9 | def __init__(self, length, initial_buffer_length=1024*1024): 10 | self._base_data = os.urandom(initial_buffer_length) 11 | self._base_data_length = initial_buffer_length 12 | self._position = 0 13 | self._remaining = length 14 | 15 | def read(self, size=None): 16 | if self._remaining == 0: 17 | return None 18 | 19 | if size is None: 20 | e = self._base_data_length 21 | else: 22 | e = size 23 | e = min(e, self._remaining) 24 | if e > self._base_data_length: 25 | self._base_data = os.urandom(e) 26 | self._base_data_length = e 27 | self._remaining = self._remaining - e 28 | return self._base_data[:e] 29 | 30 | def remaining(self): 31 | return self._remaining 32 | 33 | if len(sys.argv) == 1: 34 | print('Usage: app ') 35 | exit(1) 36 | 37 | url = sys.argv[1] 38 | size = int(sys.argv[2]) if len(sys.argv) >= 3 else 1024 39 | stream = (sys.argv[3] == "stream") if len(sys.argv) >= 4 else False 40 | 41 | print('=== Parameters ===') 42 | print(f'Url: {url}') 43 | print(f'Size: {size}') 44 | print() 45 | 46 | parsedUrl = urlparse(url) 47 | 48 | headers = { 49 | "Content-Length": str(size), 50 | "x-ms-blob-type": "BlockBlob" 51 | } 52 | 53 | # Allow self-signed SSL certs 54 | conn = http.client.HTTPSConnection(parsedUrl.netloc, context=ssl.SSLContext()) 55 | 56 | array = os.urandom(size) 57 | while True: 58 | body = LargeStream(size) if stream else array 59 | start = time.perf_counter() 60 | conn.request("PUT", url, body=body, headers=headers) 61 | resp = conn.getresponse() 62 | resp.read() 63 | stop = time.perf_counter() 64 | 65 | duration = stop - start 66 | mbps = ((size / duration) * 8) / (1024 * 1024) 67 | 68 | print(f'Put {size:,} bytes in {duration:.2f} seconds ({mbps:.2f} Mbps), Response={resp.status}') 69 | -------------------------------------------------------------------------------- /python-http-client-put/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-python-http-client-put . 2 | -------------------------------------------------------------------------------- /python-http-client-put/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-python-http-client-put . 4 | -------------------------------------------------------------------------------- /python-http-client-put/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gvanrossum/http-get-perf/e0ad2eea4a024c833849abe4bdc5578ceb6e4daa/python-http-client-put/requirements.txt -------------------------------------------------------------------------------- /python-http-client-put/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-python-http-client-put %* 2 | -------------------------------------------------------------------------------- /python-http-client-put/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-python-http-client-put "$@" 4 | -------------------------------------------------------------------------------- /python-raw-sockets/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | -------------------------------------------------------------------------------- /python-raw-sockets/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt ./ 6 | RUN pip install --no-cache-dir -r requirements.txt 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["python", "./app.py"] 11 | -------------------------------------------------------------------------------- /python-raw-sockets/app.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import sys 3 | import time 4 | import threading 5 | from urllib.parse import urlparse 6 | 7 | completed_requests = 0 8 | 9 | def execute_requests(host, port, message_bytes): 10 | global completed_requests 11 | 12 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 13 | s.connect((host, port)) 14 | 15 | while True: 16 | s.send(message_bytes) 17 | data = s.recv(200) 18 | completed_requests += 1 19 | 20 | def print_results(requests, duration): 21 | requests_per_second = requests / duration 22 | print(f'Completed {requests:,} requests in {duration:.2f} seconds ({requests_per_second:,.0f} req/s)') 23 | print() 24 | 25 | def collect_results(title, duration): 26 | global completed_requests 27 | print(f'=== {title} ===') 28 | 29 | start = time.perf_counter() 30 | completed_requests = 0 31 | time.sleep(duration) 32 | end = time.perf_counter() 33 | 34 | print_results(completed_requests, end - start) 35 | 36 | def main(): 37 | if len(sys.argv) == 1: 38 | print('Usage: app ') 39 | return 40 | 41 | url = sys.argv[1] 42 | parallel = int(sys.argv[2]) if len(sys.argv) >= 3 else 256 43 | warmup = int(sys.argv[3]) if len(sys.argv) >= 4 else 10 44 | duration = int(sys.argv[4]) if len(sys.argv) >= 5 else 10 45 | 46 | print('=== Parameters ===') 47 | print(f'Url: {url}') 48 | print(f'Parallel: {parallel}') 49 | print(f'Warmup: {warmup}') 50 | print(f'Duration: {duration}') 51 | print() 52 | 53 | parsedUrl = urlparse(url) 54 | host = parsedUrl.hostname 55 | port = parsedUrl.port 56 | path = parsedUrl.path or '/' 57 | 58 | message = f'GET {path} HTTP/1.1\r\nHost: {host}:{port}\r\n\r\n' 59 | message_bytes = message.encode() 60 | 61 | threads = [threading.Thread(target=execute_requests, args=(host, port, message_bytes), daemon=True) 62 | for i in range(parallel)] 63 | for t in threads: 64 | t.start() 65 | 66 | collect_results('Warmup', warmup) 67 | collect_results('Test', duration) 68 | 69 | # Prevent warnings due to unclosed loop/connections 70 | sys.exit() 71 | 72 | main() 73 | -------------------------------------------------------------------------------- /python-raw-sockets/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | client: 4 | build: . 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /python-raw-sockets/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gvanrossum/http-get-perf/e0ad2eea4a024c833849abe4bdc5578ceb6e4daa/python-raw-sockets/requirements.txt -------------------------------------------------------------------------------- /python-requests/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | docker-compose.yml 4 | 5 | .gitignore 6 | -------------------------------------------------------------------------------- /python-requests/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | -------------------------------------------------------------------------------- /python-requests/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt ./ 6 | RUN pip install --no-cache-dir -r requirements.txt 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["python", "./app.py"] 11 | -------------------------------------------------------------------------------- /python-requests/app.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import sys 3 | import threading 4 | import time 5 | 6 | completed_requests = 0 7 | 8 | def execute_requests(session, url): 9 | global completed_requests 10 | while True: 11 | with session.get(url) as response: 12 | response.text 13 | completed_requests += 1 14 | 15 | def print_results(requests, duration): 16 | requests_per_second = requests / duration 17 | print(f'Completed {requests:,} requests in {duration:.2f} seconds ({requests_per_second:,.0f} req/s)') 18 | print() 19 | 20 | def collect_results(title, duration): 21 | global completed_requests 22 | print(f'=== {title} ===') 23 | 24 | start = time.perf_counter() 25 | completed_requests = 0 26 | time.sleep(duration) 27 | end = time.perf_counter() 28 | 29 | print_results(completed_requests, end - start) 30 | 31 | def main(): 32 | if len(sys.argv) == 1: 33 | print('Usage: app ') 34 | return 35 | 36 | url = sys.argv[1] 37 | parallel = int(sys.argv[2]) if len(sys.argv) >= 3 else 32 38 | warmup = int(sys.argv[3]) if len(sys.argv) >= 4 else 10 39 | duration = int(sys.argv[4]) if len(sys.argv) >= 5 else 10 40 | 41 | print('=== Parameters ===') 42 | print(f'Url: {url}') 43 | print(f'Parallel: {parallel}') 44 | print(f'Warmup: {warmup}') 45 | print(f'Duration: {duration}') 46 | print() 47 | 48 | with requests.Session() as session: 49 | threads = [] 50 | for _ in range(parallel): 51 | thread = threading.Thread(target=lambda: execute_requests(session, url)) 52 | thread.daemon = True 53 | threads.append(thread) 54 | thread.start() 55 | collect_results('Warmup', warmup) 56 | collect_results('Test', duration) 57 | 58 | main() -------------------------------------------------------------------------------- /python-requests/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | client: 4 | build: . 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /python-requests/requirements.txt: -------------------------------------------------------------------------------- 1 | requests==2.25.1 2 | -------------------------------------------------------------------------------- /python-sockets/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | -------------------------------------------------------------------------------- /python-sockets/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt ./ 6 | RUN pip install --no-cache-dir -r requirements.txt 7 | 8 | COPY . . 9 | 10 | ENTRYPOINT ["python", "./app.py"] 11 | -------------------------------------------------------------------------------- /python-sockets/app.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import sys 3 | import time 4 | from urllib.parse import urlparse 5 | 6 | completed_requests = 0 7 | 8 | async def execute_requests(host, port, message_bytes): 9 | global completed_requests 10 | 11 | reader, writer = await asyncio.open_connection(host, port) 12 | 13 | while True: 14 | writer.write(message_bytes) 15 | data = await reader.read(200) 16 | completed_requests += 1 17 | 18 | def print_results(requests, duration): 19 | requests_per_second = requests / duration 20 | print(f'Completed {requests:,} requests in {duration:.2f} seconds ({requests_per_second:,.0f} req/s)') 21 | print() 22 | 23 | async def collect_results(title, duration): 24 | global completed_requests 25 | print(f'=== {title} ===') 26 | 27 | start = time.perf_counter() 28 | completed_requests = 0 29 | await asyncio.sleep(duration) 30 | end = time.perf_counter() 31 | 32 | print_results(completed_requests, end - start) 33 | 34 | async def main(): 35 | if len(sys.argv) == 1: 36 | print('Usage: app ') 37 | return 38 | 39 | url = sys.argv[1] 40 | parallel = int(sys.argv[2]) if len(sys.argv) >= 3 else 256 41 | warmup = int(sys.argv[3]) if len(sys.argv) >= 4 else 10 42 | duration = int(sys.argv[4]) if len(sys.argv) >= 5 else 10 43 | 44 | print('=== Parameters ===') 45 | print(f'Url: {url}') 46 | print(f'Parallel: {parallel}') 47 | print(f'Warmup: {warmup}') 48 | print(f'Duration: {duration}') 49 | print() 50 | 51 | parsedUrl = urlparse(url) 52 | host = parsedUrl.hostname 53 | port = parsedUrl.port 54 | path = parsedUrl.path or '/' 55 | 56 | message = f'GET {path} HTTP/1.1\r\nHost: {host}:{port}\r\n\r\n' 57 | message_bytes = message.encode() 58 | 59 | asyncio.gather(*[execute_requests(host, port, message_bytes) for i in range(parallel)]) 60 | 61 | await collect_results('Warmup', warmup) 62 | await collect_results('Test', duration) 63 | 64 | # Prevent warnings due to unclosed loop/connections 65 | sys.exit() 66 | 67 | loop = asyncio.get_event_loop() 68 | loop.run_until_complete(main()) 69 | loop.close() 70 | -------------------------------------------------------------------------------- /python-sockets/build.cmd: -------------------------------------------------------------------------------- 1 | docker build -t http-get-perf-python-sockets . 2 | -------------------------------------------------------------------------------- /python-sockets/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t http-get-perf-python-sockets . 4 | -------------------------------------------------------------------------------- /python-sockets/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | client: 4 | build: . 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /python-sockets/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gvanrossum/http-get-perf/e0ad2eea4a024c833849abe4bdc5578ceb6e4daa/python-sockets/requirements.txt -------------------------------------------------------------------------------- /python-sockets/run.cmd: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host http-get-perf-python-sockets %* 2 | -------------------------------------------------------------------------------- /python-sockets/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker run -it --rm --network host http-get-perf-python-sockets "$@" 4 | -------------------------------------------------------------------------------- /server/.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | Dockerfile 3 | 4 | .gitignore 5 | 6 | *.cmd 7 | *.sh 8 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Coverlet is a free, cross platform Code Coverage Tool 141 | coverage*[.json, .xml, .info] 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | -------------------------------------------------------------------------------- /server/Dockerfile: -------------------------------------------------------------------------------- 1 | # https://hub.docker.com/_/microsoft-dotnet-core 2 | FROM mcr.microsoft.com/dotnet/sdk:5.0.101 AS build 3 | WORKDIR /source 4 | 5 | # copy csproj and restore as distinct layers 6 | COPY *.csproj . 7 | RUN dotnet restore 8 | 9 | # copy everything else and build app 10 | COPY . . 11 | RUN dotnet publish -c release -o /app --no-restore 12 | 13 | # final stage/image 14 | FROM mcr.microsoft.com/dotnet/aspnet:5.0.1 15 | WORKDIR /app 16 | COPY --from=build /app ./ 17 | ENTRYPOINT ["dotnet", "app.dll"] 18 | -------------------------------------------------------------------------------- /server/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.Extensions.Logging; 5 | using System.Net; 6 | using System.Text; 7 | 8 | namespace App 9 | { 10 | public class Program 11 | { 12 | private static readonly byte[] _payload = Encoding.UTF8.GetBytes("Hello, World!"); 13 | private static readonly int _payloadLength = _payload.Length; 14 | 15 | public static void Main(string[] args) 16 | { 17 | new WebHostBuilder() 18 | .UseKestrel(options => 19 | { 20 | options.Listen(IPAddress.Any, 5000); 21 | options.Listen(IPAddress.Any, 5001, listenOptions => 22 | { 23 | listenOptions.UseHttps("testCert.pfx", "testPassword"); 24 | }); 25 | options.Limits.MaxRequestBodySize = null; 26 | }) 27 | .Configure(app => app.Run(async context => 28 | { 29 | if (HttpMethods.IsPut(context.Request.Method)) 30 | { 31 | long bytesRead = 0; 32 | 33 | var reader = context.Request.BodyReader; 34 | while (true) 35 | { 36 | var result = await reader.ReadAsync(); 37 | bytesRead += result.Buffer.Length; 38 | reader.AdvanceTo(result.Buffer.End); 39 | if (result.IsCompleted) 40 | { 41 | break; 42 | } 43 | } 44 | 45 | var payload = Encoding.UTF8.GetBytes(bytesRead.ToString()); 46 | context.Response.StatusCode = 200; 47 | context.Response.ContentType = "text/plain"; 48 | context.Response.ContentLength = payload.Length; 49 | await context.Response.Body.WriteAsync(payload, 0, payload.Length); 50 | } 51 | else 52 | { 53 | context.Response.StatusCode = 200; 54 | context.Response.ContentType = "text/plain"; 55 | context.Response.ContentLength = _payloadLength; 56 | await context.Response.Body.WriteAsync(_payload, 0, _payloadLength); 57 | } 58 | })) 59 | .Build() 60 | .Run(); 61 | } 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "app": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "ASPNETCORE_ENVIRONMENT": "Development" 7 | }, 8 | "applicationUrl": "http://localhost:5000" 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /server/app.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | PreserveNewest 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /server/app.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30320.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "app", "app.csproj", "{BC75F8D9-5B7B-4048-AAB2-5EC886C8C71F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BC75F8D9-5B7B-4048-AAB2-5EC886C8C71F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {BC75F8D9-5B7B-4048-AAB2-5EC886C8C71F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {BC75F8D9-5B7B-4048-AAB2-5EC886C8C71F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {BC75F8D9-5B7B-4048-AAB2-5EC886C8C71F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {906D1843-555E-4D09-972F-D2284C317EB9} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /server/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | server: 4 | build: . 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /server/testCert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gvanrossum/http-get-perf/e0ad2eea4a024c833849abe4bdc5578ceb6e4daa/server/testCert.pfx -------------------------------------------------------------------------------- /wrk/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | client: 4 | image: williamyeh/wrk:4.0.2 5 | network_mode: "host" 6 | -------------------------------------------------------------------------------- /wrk2/run.sh: -------------------------------------------------------------------------------- 1 | docker run -it --rm --network host 1vlad/wrk2-docker "$@" 2 | --------------------------------------------------------------------------------