Debian Codegraph @

script/benchmark/tools/table.sh

raw
1 #!/bin/bash
2
3 # Copyright The containerd Authors.
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8
9 # http://www.apache.org/licenses/LICENSE-2.0
10
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 set -euo pipefail
18
19 JSON="$(mktemp)"
20 cat > "${JSON}"
21
22 CONTEXT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/"
23 source "${CONTEXT}/util.sh"
24
25 MODES=( ${TARGET_MODES:-} )
26 if [ ${#MODES[@]} -eq 0 ] ; then
27 MODES=("legacy" "estargz-noopt" "estargz" "zstdchunked")
28 fi
29
30 IMAGES=( ${TARGET_IMAGES:-} )
31 if [ ${#IMAGES[@]} -eq 0 ] ; then
32 IMAGES=( $(cat "${JSON}" | jq -r '[ .[] | select(.mode=="'${MODES[0]}'").repo ] | unique[]') )
33 fi
34
35 # Ensure we use the exact same number of samples among benchmarks
36 MINSAMPLES=
37 for IMGNAME in "${IMAGES[@]}" ; do
38 for MODE in "${MODES[@]}"; do
39 THEMIN=$(min_samples "${JSON}" "${IMGNAME}" "${MODE}")
40 if [ "${MINSAMPLES}" == "" ] ; then
41 MINSAMPLES="${THEMIN}"
42 fi
43 MINSAMPLES=$(echo "${MINSAMPLES} ${THEMIN}" | tr ' ' '\n' | sort -n | head -1)
44 done
45 done
46
47 cat <<EOF
48 # Benchmarking Result (${PERCENTILE} pctl.,samples=${MINSAMPLES})
49
50 Runs on the ubuntu-22.04 runner on Github Actions.
51 EOF
52
53 for IMGNAME in "${IMAGES[@]}" ; do
54 cat <<EOF
55
56 ## ${IMGNAME}
57
58 |mode|pull(sec)|create(sec)|run(sec)|
59 ---|---|---|---
60 EOF
61
62 for MODE in "${MODES[@]}"; do
63 PULLTIME=$(percentile "${JSON}" "${MINSAMPLES}" "${IMGNAME}" "${MODE}" "elapsed_pull")
64 CREATETIME=$(percentile "${JSON}" "${MINSAMPLES}" "${IMGNAME}" "${MODE}" "elapsed_create")
65 RUNTIME=$(percentile "${JSON}" "${MINSAMPLES}" "${IMGNAME}" "${MODE}" "elapsed_run")
66 echo "|${MODE}|${PULLTIME}|${CREATETIME}|${RUNTIME}|"
67 done
68 done