summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-18 15:51:35 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-22 17:33:25 +0100
commitba2e44d4d72aa31246aa9ed06a655a446f885f12 (patch)
treefc6c88cbf880191f25eaafe7ed47852fdb1fd4cd /scripts
parent66e6946b8c22fca826fde9f08c89cff056a1d6f4 (diff)
downloadqtlocation-mapboxgl-ba2e44d4d72aa31246aa9ed06a655a446f885f12.tar.gz
[build] publish binary size statistics to S3
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/log_binary_size.sh26
-rwxr-xr-xscripts/publish_binary_size.sh75
2 files changed, 91 insertions, 10 deletions
diff --git a/scripts/log_binary_size.sh b/scripts/log_binary_size.sh
index 5de9438c53..3c55be15f1 100755
--- a/scripts/log_binary_size.sh
+++ b/scripts/log_binary_size.sh
@@ -2,16 +2,10 @@
set -e
set -o pipefail
+set -u
-function filesize {
- if [ `uname -s` = 'Darwin' ]; then
- stat -f%z $1
- else
- stat --printf=%s $1
- fi
-}
+# Logs metrics on binary size to CloudWatch
-# Uploads build metrics to CloudWatch
FILE=$1
DIMENSIONS=$2
@@ -20,16 +14,28 @@ if [ -z "${DIMENSIONS}" ]; then
exit 1
fi
+function filesize {
+ if [ `uname -s` = 'Darwin' ]; then
+ stat -f%z $1
+ else
+ stat --printf=%s $1
+ fi
+}
+
if [ -f "${FILE}" ]; then
SIZE=`filesize ${FILE}`
- echo "* Reporting `LC_NUMERIC=en_US printf "%'10.f\n" ${SIZE}` bytes for '${DIMENSIONS}' (${FILE})"
- if [ ${CLOUDWATCH} ]; then
+ if [ ${CLOUDWATCH:-} ]; then
+ echo "* Reporting `LC_NUMERIC=en_US printf "%'10.f\n" ${SIZE}` bytes for '${DIMENSIONS}' (${FILE})"
aws --region us-east-1 cloudwatch put-metric-data \
--namespace "Mapbox/GL" \
--metric-name "BinarySize" \
--unit "Bytes" \
--value ${SIZE} \
--dimensions "${DIMENSIONS}"
+
+ ./scripts/publish_binary_size.sh "${DIMENSIONS}"
+ else
+ echo "* Measured `LC_NUMERIC=en_US printf "%'10.f\n" ${SIZE}` bytes for '${DIMENSIONS}' (${FILE})"
fi
else
echo "* File '${FILE}' does not exist"
diff --git a/scripts/publish_binary_size.sh b/scripts/publish_binary_size.sh
new file mode 100755
index 0000000000..d5ab71b8c4
--- /dev/null
+++ b/scripts/publish_binary_size.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+
+set -e
+set -o pipefail
+set -u
+
+# Downloads log data from AWS CloudWatch and uploads it as a JSON file to S3 for public access.
+
+function publish_binary_size {
+ local DIMENSIONS=$1
+
+ if [ -z "${DIMENSIONS}" ]; then
+ echo "* No dimensions specified"
+ exit 1
+ fi
+
+ function print_dimensions {
+ for ITEM in ${DIMENSIONS//,/ } ; do
+ echo -n "Name=${ITEM//=/,Value=} "
+ done
+ }
+
+ local DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ"
+ local DATE_END=$(date -u +${DATE_FORMAT})
+
+ if [ `uname -s` = 'Darwin' ]; then # BSD date
+ local DATE_BEGIN=$(date -jf "${DATE_FORMAT}" -v-30d "${DATE_END}" +"${DATE_FORMAT}")
+ else # GNU date
+ local DATE_BEGIN=$(date --date="${DATE_END} - 30 days" +"${DATE_FORMAT}")
+ fi
+
+ # Download the metrics, gzip, and upload to S3.
+ aws --region us-east-1 cloudwatch get-metric-statistics \
+ --namespace "Mapbox/GL" \
+ --metric-name "BinarySize" \
+ --unit "Bytes" \
+ --start-time "${DATE_BEGIN}" \
+ --end-time "${DATE_END}" \
+ --period 3600 \
+ --statistics Maximum \
+ --dimensions `print_dimensions` \
+ | gzip | aws s3 cp \
+ --acl public-read \
+ --cache-control "max-age=300" \
+ --content-encoding gzip \
+ --content-type application/json \
+ - "s3://mapbox/mapbox-gl-native/metrics/binary-size/${DIMENSIONS}.json"
+
+ echo "* Uploaded data to 's3://mapbox/mapbox-gl-native/metrics/binary-size/${DIMENSIONS}.json'"
+}
+
+if [ $# -gt 0 ]; then
+ # Upload the specified dimension only
+ publish_binary_size "$1"
+else
+ # Upload all dimensions that we are tracking
+ publish_binary_size "Platform=iOS,Arch=armv7"
+ publish_binary_size "Platform=iOS,Arch=arm64"
+ publish_binary_size "Platform=iOS,Arch=i386"
+ publish_binary_size "Platform=iOS,Arch=x86_64"
+ publish_binary_size "Platform=iOS,Arch=Dynamic"
+
+ publish_binary_size "Platform=macOS,Arch=x86_64"
+
+ publish_binary_size "Platform=Linux,Compiler=clang-3.8,Arch=x86_64"
+ publish_binary_size "Platform=Linux,Compiler=gcc-5,Arch=x86_64"
+
+ publish_binary_size "Platform=Android,Arch=arm-v5"
+ publish_binary_size "Platform=Android,Arch=arm-v7"
+ publish_binary_size "Platform=Android,Arch=arm-v8"
+ publish_binary_size "Platform=Android,Arch=x86"
+ publish_binary_size "Platform=Android,Arch=x86_64"
+ publish_binary_size "Platform=Android,Arch=mips"
+ publish_binary_size "Platform=Android,Arch=Archive"
+fi