forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-benchmarks-s3.sh
executable file
·64 lines (56 loc) · 1.67 KB
/
upload-benchmarks-s3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -euo pipefail
# ci-upload-benchmarks-s3.sh
#
# SUMMARY
#
# This uploads raw criterion benchmark results to S3 for later analysis via
# Athena.
#
# It should only be run in CI as we want to ensure that the benchmark
# environment is consistent.
if ! (${CI:-false}); then
echo "Aborted: this script is for use in CI, benchmark analysis depends on a consistent bench environment" >&2
exit 1
fi
escape() {
# /s mess up Athena partitioning
echo "${1//\//\#}"
}
S3_BUCKET=${S3_BUCKET:-test-artifacts.vector.dev}
BENCHES_VERSION="2" # bump if S3 schema changes
ENVIRONMENT_VERSION="1" # bump if bench environment changes
VECTOR_THREADS=${VECTOR_THREADS:-$(nproc)}
LIBC="gnu"
target="$1"
git_branch=$(git branch --show-current)
git_rev_count=$(git rev-list --count HEAD)
git_sha=$(git rev-parse HEAD)
machine=$(uname --machine)
operating_system=$(uname --kernel-name)
year=$(date +"%Y")
month=$(date +"%m")
day=$(date +"%d")
timestamp=$(date +"%s")
object_name="$(echo "s3://$S3_BUCKET/benches/\
benches_version=${BENCHES_VERSION}/\
environment_version=${ENVIRONMENT_VERSION}/\
branch=$(escape "${git_branch}")/\
target=${target}/\
machine=${machine}/\
operating_system=${operating_system}/\
libc=${LIBC}/\
threads=${VECTOR_THREADS}/\
year=${year}/\
month=${month}/\
day=${day}/\
rev_count=${git_rev_count}/\
sha=${git_sha}/\
timestamp=${timestamp}/\
raw.csv" | tr '[:upper:]' '[:lower:]'
)"
(
echo 'group,function,value,throughput_num,throughput_type,sample_measured_value,unit,iteration_count' ;
find target/criterion -type f -path '*/new/*' -name raw.csv -exec bash -c 'cat "$1" | tail --lines +2' _ {} \;
) | aws s3 cp - "$object_name"
echo "wrote $object_name"