Skip to content

Commit

Permalink
[Core] [Perf] Comparison b/w Node 18 fetch with core clients (Azure#2…
Browse files Browse the repository at this point in the history
…1544)

* node 17.5 fetch - checkpoint

* new tests

* add base test and other tests

* lock file

* readme with commands and results from codespaces

* rushx build

* undo changes to storage and test-utils

* Update sdk/core/perf-tests/core-rest-pipeline/package.json

* keepAlive set to true

* compile error fix

* Add url option to BaseHttpTest

* Add test for http.request

* Add test for undici.request

* Update sdk/core/perf-tests/core-rest-pipeline/package.json

Co-authored-by: Mike Harder <[email protected]>

* port updates and otjer build updates, more tests and results and commands and rush update

* remove node-fetch test

* format

* lock file from main

* lock file

* minor feedback

* from main

* rush update

* lock file

Co-authored-by: Mike Harder <[email protected]>
  • Loading branch information
HarshaNalluru and mikeharder authored Jun 13, 2022
1 parent 9f5e364 commit 1c9df44
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 35 deletions.
104 changes: 80 additions & 24 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions sdk/core/perf-tests/core-rest-pipeline/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
### Guide

1. Build the core-rest-pipeline perf tests package `rush build -t perf-core-rest-pipeline`.
3. Copy the `sample.env` file and name it as `.env`.
4. Populate the `.env` file with your Azure Credentials.
5. Refer to the [rate limits](https://docs.microsoft.com/azure/active-directory/enterprise-users/directory-service-limits-restrictions) and then run the tests as follows:
2. Copy the `sample.env` file and name it as `.env`.
3. Populate the `.env` file with your Azure Credentials.
4. Refer to the [rate limits](https://docs.microsoft.com/azure/active-directory/enterprise-users/directory-service-limits-restrictions) and then run the tests as follows:

- `bearerTokenAuthenticationPolicy` test for the `challengeCallbacks`, for simple `WWW-Authenticate` challenges.
- `npm run perf-test:node -- BearerTokenAuthenticationPolicyChallengeTest --warmup 1 --iterations 1 --parallel 5`
- Comparing various HTTP clients...
- `npm run perf-test:node -- FetchTest --warmup 1 --iterations 1 --parallel 5` [ 6,693.39 ops/sec ]
- `npm run perf-test:node -- UndiciRequestTest --warmup 1 --iterations 1 --parallel 5` [ 19,733.93 ops/sec ]
- `npm run perf-test:node -- CoreRestPipelineTest --warmup 1 --iterations 1 --parallel 5` [ 17,519.69 ops/sec]
- `npm run perf-test:node -- CoreHTTPTest --warmup 1 --iterations 1 --parallel 5` [ 4,498.91 ops/sec]
- `npm run perf-test:node -- HttpRequestTest --warmup 1 --iterations 1 --parallel 5` [ 19,632.64 ops/sec]
[ -- number ops/sec -- ] are from a codespaces instance
14 changes: 10 additions & 4 deletions sdk/core/perf-tests/core-rest-pipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
"author": "",
"license": "ISC",
"dependencies": {
"@azure/core-http": "^2.2.4",
"@azure/core-rest-pipeline": "^1.1.0",
"@azure/core-auth": "^1.3.0",
"@azure/test-utils-perf": "^1.0.0",
"dotenv": "^8.2.0"
"dotenv": "^8.2.0",
"undici": "^5.0.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/node": "^17.0.22",
"@types/uuid": "^8.0.0",
"eslint": "^8.0.0",
"@types/express": "^4.17.13",
"concurrently": "^6.2.1",
"cross-env": "^7.0.3",
"express": "^4.17.3",
"eslint": "^7.15.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.0",
"ts-node": "^10.0.0",
Expand All @@ -31,7 +37,7 @@
"build": "npm run clean && tsc -p .",
"build:test": "echo skipped",
"check-format": "prettier --list-different --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-esm test-dist types *.tgz *.log",
"clean": "rimraf dist dist-esm test-dist types *.tgz *.log ",
"format": "prettier --write --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
Expand Down
52 changes: 52 additions & 0 deletions sdk/core/perf-tests/core-rest-pipeline/test/baseHttpTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import express from "express";
import { PerfOptionDictionary, PerfTest } from "@azure/test-utils-perf";
import { Server } from "http";
import { AddressInfo } from "net";

let app: express.Application;
let server: Server;

export interface BaseHttpTestOptions {
url: string;
}

export abstract class BaseHttpTest extends PerfTest<BaseHttpTestOptions> {
url!: string;

options: PerfOptionDictionary<BaseHttpTestOptions> = {
url: {
description: "URL to fetch. If empty, fetches from express server on localhost.",
shortName: "u",
longName: "url",
},
};

async globalSetup() {
if (this.parsedOptions.url.value) {
this.url = this.parsedOptions.url.value;
} else {
// Use test server if URL is not specified on the command-line
app = express();

app.get("/", (_, res) => {
res.send("Hello world!");
});

server = app.listen(0, () => {
console.log("Listening on port:", (server.address() as AddressInfo).port);
});

this.url = `http://localhost:${(server.address() as AddressInfo).port}`;
}
}

async globalCleanup() {
if (!this.parsedOptions.url.value) {
// URL is not specified on the command-line, means we created the test server, closing that now
server.close();
}
}
}
Loading

0 comments on commit 1c9df44

Please sign in to comment.