Debian Codegraph @

script/benchmark/tools/csv.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 INDEX="image,operation"
48 for MODE in "${MODES[@]}"; do
49 INDEX="${INDEX},${MODE}"
50 done
51 echo "${INDEX}"
52 for IMGNAME in "${IMAGES[@]}" ; do
53 PULLLINE="${IMGNAME},pull"
54 for MODE in "${MODES[@]}"; do
55 PULLTIME=$(percentile "${JSON}" "${MINSAMPLES}" "${IMGNAME}" "${MODE}" "elapsed_pull")
56 PULLLINE="${PULLLINE},${PULLTIME}"
57 done
58 echo "${PULLLINE}"
59
60 CREATELINE="${IMGNAME},create"
61 for MODE in "${MODES[@]}"; do
62 CREATETIME=$(percentile "${JSON}" "${MINSAMPLES}" "${IMGNAME}" "${MODE}" "elapsed_create")
63 CREATELINE="${CREATELINE},${CREATETIME}"
64 done
65 echo "${CREATELINE}"
66
67 RUNLINE="${IMGNAME},run"
68 for MODE in "${MODES[@]}"; do
69 RUNTIME=$(percentile "${JSON}" "${MINSAMPLES}" "${IMGNAME}" "${MODE}" "elapsed_run")
70 RUNLINE="${RUNLINE},${RUNTIME}"
71 done
72 echo "${RUNLINE}"
73 done