forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] [Perf] Comparison b/w Node 18 fetch with core clients (Azure#2…
…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
1 parent
9f5e364
commit 1c9df44
Showing
11 changed files
with
325 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
sdk/core/perf-tests/core-rest-pipeline/test/baseHttpTest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.