Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion scripts/model-analysis/model-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const root = path.join(__dirname, "..", "..");

const models = path.join(root, "codegen", "sdk-codegen", "aws-models");

const protocolCounts = {};

for (const file of fs.readdirSync(models)) {
if (file.endsWith(".json")) {
const model = require(path.join(models, file));
Expand All @@ -17,7 +19,12 @@ for (const file of fs.readdirSync(models)) {
const operations = Object.entries(shapes).filter(([id, s]) => {
return s.type === "operation";
});
const protocol = Object.entries(service[1].traits).find(([id, trait]) => id.startsWith("aws.protocol"))[0];
const protocol = Object.entries(service[1].traits).find(
([id, trait]) => id.startsWith("aws.protocol") || id.startsWith("smithy.protocol")
)[0];

protocolCounts[protocol] = protocolCounts[protocol] ?? {};
protocolCounts[protocol][service[0]] = operations.length;

if (protocol.includes("rest")) {
const inputOutputShapes = Object.entries(shapes).filter(([id, s]) => {
Expand Down Expand Up @@ -129,3 +136,15 @@ for (const file of fs.readdirSync(models)) {
}
}
}

for (const [protocol, serviceToOperationCounts] of Object.entries(protocolCounts)) {
const entries = Object.entries(serviceToOperationCounts).sort(([s1, c1], [s2, c2]) => {
return c2 - c1;
});
for (const [s, c] of entries) {
delete serviceToOperationCounts[s];
serviceToOperationCounts[s] = c;
}
}

console.log(protocolCounts);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logs out the models per protocol with the highest operation count

5 changes: 4 additions & 1 deletion tests/bundlers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ webpack:

esbuild:
npx esbuild ./source.ts --bundle --outfile=./dist/esbuild-dist.js --format=esm --tree-shaking=true
npx esbuild ./source.ts --bundle --outfile=./dist-min/esbuild-dist.min.js --format=esm --tree-shaking=true --minify
npx esbuild ./source.ts --bundle --outfile=./dist-min/esbuild-dist.min.js --format=esm --tree-shaking=true --minify

clean:
rm -rf dist dist-min dist-vite dist-esbuild dist-webpack
2 changes: 2 additions & 0 deletions tests/bundlers/applications/lib-dynamodb-single-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb";
export { DynamoDBClient } from "@aws-sdk/client-dynamodb";
4 changes: 4 additions & 0 deletions tests/bundlers/applications/multi-protocols.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// group of most used protocols
// excludes CBOR, Query, EC2, and JSON RPC 1.1

export { AwsRestJsonProtocol, AwsRestXmlProtocol, AwsJson1_0Protocol } from "@aws-sdk/core/protocols";
2 changes: 2 additions & 0 deletions tests/bundlers/applications/sdk-connect-aggregate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// rest json
export { Connect } from "@aws-sdk/client-connect";
2 changes: 2 additions & 0 deletions tests/bundlers/applications/sdk-connect-single-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// rest json
export { ConnectClient, ListLambdaFunctionsCommand } from "@aws-sdk/client-connect";
12 changes: 6 additions & 6 deletions tests/bundlers/runner/BundlerSizeBenchmarker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class BundlerSizeBenchmarker {
* @returns {Promise<{app:string,size:string,bundler:string}>}
*/
async webpack() {
const outfile = path.resolve(__dirname, "..", "dist", `webpack-dist-${this.application}.js`);
const outfile = path.resolve(__dirname, "..", "dist-webpack", `webpack-dist-${this.application}.js`);

const config = {
mode: "production",
Expand Down Expand Up @@ -72,14 +72,14 @@ export class BundlerSizeBenchmarker {
},
minify: true,
emptyOutDir: false,
worker: {
format: "es",
},
rollupOptions: {
input: {
input: inputFile,
},
external: [],
output: {
format: "esm",
dir: path.dirname(outfile),
inlineDynamicImports: true,
},
},
},
Expand All @@ -95,7 +95,7 @@ export class BundlerSizeBenchmarker {
*/
async esbuild() {
const entryPoint = path.resolve(__dirname, "..", "applications", this.application);
const outfile = path.resolve(__dirname, "..", "dist", `esbuild-dist-${this.application}.js`);
const outfile = path.resolve(__dirname, "..", "dist-esbuild", `esbuild-dist-${this.application}.js`);

await esbuild.build({
entryPoints: [entryPoint],
Expand Down
Loading