Skip to content

Commit 84555a1

Browse files
committed
test: use S3_BUCKET environment variable for benchmark
1 parent bf5aeb0 commit 84555a1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

benchmark/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
The [benchmark.sh script](./benchmark.sh) is a bash script to compare the cold-start time of using the AWS Lambda Powertools in a semi-automated way. It does so by deploying two Lambda functions which both have the aws-lambda-powertools module installed. One Lambda function will import and initialize the three main utilities (`Metrics`, `Logger`, `Tracer`), while the other one will not.
44

5+
Please note that this requires the [SAM CLI](https://github.com/aws/aws-sam-cli) version 1.2.0 or later.
6+
57
## Usage
68

79
To use the script, you should move into the benchmark folder and run the benchmark script:
810

911
```
12+
export S3_BUCKET=code-artifact-s3-bucket
13+
1014
cd benchmark
1115
./benchmark.sh
1216
```

benchmark/benchmark.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
set -e
44
trap cleanup EXIT
55

6+
if [ -z "S3_BUCKET" ]; then
7+
echo "Missing S3_BUCKET environment variabe"
8+
exit 1
9+
fi
10+
611
export BENCHMARK_STACK_NAME=${BENCHMARK_STACK_NAME:-"powertools-benchmark"}
712

813
function cleanup {
@@ -39,7 +44,7 @@ function get_stats {
3944
# Build and deploy the benchmark stack
4045
echo "Building and deploying..."
4146
sam build
42-
sam deploy --stack-name $BENCHMARK_STACK_NAME --guided
47+
sam deploy --stack-name $BENCHMARK_STACK_NAME --s3-bucket $S3_BUCKET --capabilities CAPABILITY_IAM
4348

4449
# Retrieve output values
4550
echo "Retrieve values..."
@@ -69,11 +74,10 @@ echo
6974
# Gather statistics
7075
# Waiting 2.5 minutes to make sure the data propagates from CloudWatch Logs
7176
# into CloudWatch Logs Insights.
77+
echo "Waiting for data to propagate in CloudWatch Logs Insights..."
7278
sleep 150
7379
return_code=0
74-
echo -n "INSTRUMENTED="
75-
get_stats $INSTRUMENTED_LOG_GROUP
76-
echo -n "REFERENCE="
77-
get_stats $REFERENCE_LOG_GROUP
80+
echo "INSTRUMENTED=$(get_stats $INSTRUMENTED_LOG_GROUP)"
81+
echo "REFERENCE=$(get_stats $REFERENCE_LOG_GROUP)"
7882

7983
exit $return_code

0 commit comments

Comments
 (0)