Skip to content

Commit

Permalink
add benchmarks (#100)
Browse files Browse the repository at this point in the history
* add benchmarks

* Format with Black

* refactor: renamed chrome benchmark and edited markdown2html lambda code and payload

* Format with Black

* add source codes

Co-authored-by: Github Actions Bot <>
Co-authored-by: Arshia Moghimi <arshiamoghimi98@gmail.com>
  • Loading branch information
joehattori and arshiamoghimi authored Nov 21, 2022
1 parent fbb36ac commit 08ed093
Show file tree
Hide file tree
Showing 23 changed files with 873 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "benchmarks/formplug/formplug"]
path = benchmarks/formplug/formplug
url = https://github.com/danielireson/formplug
[submodule "benchmarks/ocr/lambda-OCRmyPDF"]
path = benchmarks/ocr/lambda-OCRmyPDF
url = https://github.com/chronograph-pe/lambda-OCRmyPDF.git
21 changes: 21 additions & 0 deletions benchmarks/formplug/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Daniel Ireson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions benchmarks/formplug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This benchmark is from [https://github.com/danielireson/formplug](https://github.com/danielireson/formplug).
Follow the [instructions](https://github.com/danielireson/formplug#setup) to deploy it to AWS.
1 change: 1 addition & 0 deletions benchmarks/formplug/formplug
Submodule formplug added at 5d7155
21 changes: 21 additions & 0 deletions benchmarks/markdown2html/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Princeton University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions benchmarks/markdown2html/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This benchmark was taken from [faas-profiler](https://github.com/PrincetonUniversity/faas-profiler/blob/master/functions/markdown-to-html/markdown2html.py).
We modified the code for our own purposes.
15 changes: 15 additions & 0 deletions benchmarks/markdown2html/lambda_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import markdown
import base64


def lambda_handler(event, context):
try:
text = event["markdown"]
except:
return {"Error": "Possibly lacking markdown parameter in request."}

decoded_text = base64.b64decode(text.encode()).decode()

html = markdown.markdown(decoded_text)

return {"html_response": html}
661 changes: 661 additions & 0 deletions benchmarks/ocr/LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions benchmarks/ocr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This benchmark is taken from [https://github.com/chronograph-pe/lambda-OCRmyPDF](https://github.com/chronograph-pe/lambda-OCRmyPDF).
Running `./deploy.sh` deploys the function to AWS.
21 changes: 21 additions & 0 deletions benchmarks/ocr/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -eu

lambda_name=$1
s3_bucket=$2
s3_file_key=$3

zip_file_name="lambda-ocrtopdf.zip"
download_url="https://github.com/chronograph-pe/lambda-OCRmyPDF/releases/download/v1.0-alpha/lambda-ocrtopdf.zip"

wget -O $zip_file_name $download_url

aws s3 cp $zip_file_name s3://$s3_bucket/$s3_file_key
aws lambda update-function-code --function-name $lambda_name --s3-bucket $s3_bucket --s3-key $s3_file_key
aws lambda update-function-configuration --function-name $lambda_name \
--handler apply-ocr-to-s3-object.apply_ocr_to_document_handler \
--environment "Variables={PATH=/var/task/bin,PYTHONPATH=/var/task/python,TESSDATA_PREFIX=/var/task/tessdata}" \
--timeout 900 \
--memory-size 3008 \
--runtime "python3.6"
1 change: 1 addition & 0 deletions benchmarks/ocr/lambda-OCRmyPDF
Submodule lambda-OCRmyPDF added at 3b11b9
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions configs/formplug/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"function_name": "formplug-dev-receive",
"mem_bounds": [
128,
1024
],
"mem_size": 128,
"region": "us-east-1",
"vendor": "AWS",
"workload": {
"instances": {
"instance1": {
"application": "formplug-dev-receive",
"payload": "payload.json"
}
},
"random_seed": 100,
"test_duration_in_seconds": 15,
"test_name": "IntegrationTest1"
}
}
9 changes: 9 additions & 0 deletions configs/formplug/payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"SERVICE_NAME": "formplug",
"ENCRYPTION_KEY": "formsaregreat",
"REGION": "us-east-1",
"STAGE": "dev",
"SENDER_ARN": "arn:aws:ses:us-east-1:880306299867:identity/arshiamoghimi77@gmail.com",
"WHITELISTED_RECIPIENTS": null,
"RECAPTCHA_SECRET_KEY": null
}
11 changes: 11 additions & 0 deletions configs/formplug/workload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"instances": {
"instance1": {
"application": "formplug-dev-receive",
"payload": "payload.json"
}
},
"random_seed": 100,
"test_duration_in_seconds": 15,
"test_name": "IntegrationTest1"
}
21 changes: 21 additions & 0 deletions configs/markdown2html/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"function_name": "markdown2html",
"mem_bounds": [
128,
1024
],
"mem_size": 128,
"region": "us-east-1",
"vendor": "AWS",
"workload": {
"instances": {
"instance1": {
"application": "markdown2html",
"payload": "payload.json"
}
},
"random_seed": 100,
"test_duration_in_seconds": 15,
"test_name": "IntegrationTest1"
}
}
3 changes: 3 additions & 0 deletions configs/markdown2html/payload.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions configs/markdown2html/workload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"instances": {
"instance1": {
"application": "markdown2html",
"payload": "payload.json"
}
},
"random_seed": 100,
"test_duration_in_seconds": 15,
"test_name": "IntegrationTest1"
}
21 changes: 21 additions & 0 deletions configs/ocr/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"function_name": "ocr",
"mem_bounds": [
128,
1024
],
"mem_size": 128,
"region": "us-east-1",
"vendor": "AWS",
"workload": {
"instances": {
"instance1": {
"application": "ocr",
"payload": "payload.json"
}
},
"random_seed": 100,
"test_duration_in_seconds": 15,
"test_name": "IntegrationTest1"
}
}
12 changes: 12 additions & 0 deletions configs/ocr/payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"pages": "4",
"awsRegion": "us-east-1",
"s3": {
"bucket": {
"name": "larmol-public"
},
"object": {
"key": "socc21_multi-cloud_serverless.pdf"
}
}
}
11 changes: 11 additions & 0 deletions configs/ocr/workload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"instances": {
"instance1": {
"application": "ocr",
"payload": "payload.json"
}
},
"random_seed": 100,
"test_duration_in_seconds": 15,
"test_name": "IntegrationTest1"
}

0 comments on commit 08ed093

Please sign in to comment.