-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sam
committed
Jan 17, 2023
1 parent
762934d
commit 7f85e18
Showing
15 changed files
with
1,073 additions
and
73 deletions.
There are no files selected for viewing
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,4 +1,6 @@ | ||
lib/ | ||
node_modules/ | ||
sdk.generated.ts | ||
.bundle | ||
.bundle | ||
*.tgz | ||
cdk.out |
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,10 @@ | ||
{ | ||
"name": "@benchmark/functions", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"dependencies": { | ||
"itty-aws": "workspace:^", | ||
"@aws-sdk/client-dynamodb": "^3.245.0" | ||
} | ||
} |
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,19 @@ | ||
import { AWS } from "itty-aws"; | ||
|
||
const client = new AWS.DynamoDB(); | ||
|
||
const TableName = process.env.TABLE_NAME!; | ||
|
||
export async function handler() { | ||
await client.putItem({ | ||
TableName, | ||
Item: { | ||
pk: { | ||
S: "pk", | ||
}, | ||
prop: { | ||
S: "value", | ||
}, | ||
}, | ||
}); | ||
} |
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,21 @@ | ||
import { DynamoDB } from "aws-sdk"; | ||
|
||
const client = new DynamoDB(); | ||
|
||
const TableName = process.env.TABLE_NAME!; | ||
|
||
export async function handler() { | ||
await client | ||
.putItem({ | ||
TableName, | ||
Item: { | ||
pk: { | ||
S: "pk", | ||
}, | ||
prop: { | ||
S: "value", | ||
}, | ||
}, | ||
}) | ||
.promise(); | ||
} |
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,21 @@ | ||
import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb"; | ||
|
||
const client = new DynamoDBClient({}); | ||
|
||
const TableName = process.env.TABLE_NAME!; | ||
|
||
export async function handler() { | ||
await client.send( | ||
new PutItemCommand({ | ||
TableName, | ||
Item: { | ||
pk: { | ||
S: "pk", | ||
}, | ||
prop: { | ||
S: "value", | ||
}, | ||
}, | ||
}) | ||
); | ||
} |
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,8 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["src"], | ||
"exclude": ["lib", "node_modules"], | ||
"compilerOptions": { | ||
"outDir": "lib" | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"app": "ts-node ./src/index.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,21 @@ | ||
{ | ||
"name": "@benchmark/infra", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"synth": "cdk synth", | ||
"deploy": "cdk deploy", | ||
"hotswap": "cdk deploy --hotswap" | ||
}, | ||
"dependencies": { | ||
"aws-cdk-lib": "^2.60.0", | ||
"@benchmark/functions": "workspace:^" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16", | ||
"aws-cdk": "^2.60.0", | ||
"constructs": "^10", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4" | ||
} | ||
} |
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,64 @@ | ||
import { | ||
App, | ||
aws_dynamodb, | ||
aws_lambda, | ||
aws_lambda_nodejs, | ||
Stack, | ||
} from "aws-cdk-lib"; | ||
|
||
const app = new App(); | ||
|
||
const stack = new Stack(app, "itty-benchmark"); | ||
|
||
const table = new aws_dynamodb.Table(stack, "Table", { | ||
partitionKey: { | ||
name: "pk", | ||
type: aws_dynamodb.AttributeType.STRING, | ||
}, | ||
billingMode: aws_dynamodb.BillingMode.PAY_PER_REQUEST, | ||
}); | ||
|
||
const props = { | ||
environment: { | ||
TABLE_NAME: table.tableName, | ||
}, | ||
memorySize: 512, | ||
}; | ||
|
||
const ittyFunc = new aws_lambda_nodejs.NodejsFunction(stack, "IttyFunc", { | ||
functionName: "benchmark-itty", | ||
runtime: aws_lambda.Runtime.NODEJS_18_X, | ||
entry: require.resolve("@benchmark/functions/lib/itty-handler"), | ||
bundling: { | ||
externalModules: ["@aws-sdk/*"], | ||
}, | ||
...props, | ||
}); | ||
|
||
const v3BundledFunc = new aws_lambda_nodejs.NodejsFunction(stack, "V3Bundled", { | ||
functionName: "benchmark-v3-bundled", | ||
runtime: aws_lambda.Runtime.NODEJS_18_X, | ||
entry: require.resolve("@benchmark/functions/lib/itty-handler"), | ||
bundling: { | ||
externalModules: [], | ||
}, | ||
...props, | ||
}); | ||
|
||
const v3ExcludedFunc = new aws_lambda_nodejs.NodejsFunction( | ||
stack, | ||
"V3Excluded", | ||
{ | ||
functionName: "benchmark-v3-excluded", | ||
runtime: aws_lambda.Runtime.NODEJS_18_X, | ||
entry: require.resolve("@benchmark/functions/lib/itty-handler"), | ||
bundling: { | ||
externalModules: ["@aws-sdk/*"], | ||
}, | ||
...props, | ||
} | ||
); | ||
|
||
table.grantReadWriteData(ittyFunc); | ||
table.grantReadWriteData(v3BundledFunc); | ||
table.grantReadWriteData(v3ExcludedFunc); |
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,11 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["src"], | ||
"exclude": ["lib", "node_modules"], | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"module": "CommonJS", | ||
"moduleResolution": "Node", | ||
"target": "ES2022" | ||
} | ||
} |
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
Oops, something went wrong.