forked from kata-containers/kata-containers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
blogbench.sh
executable file
·127 lines (109 loc) · 3.81 KB
/
blogbench.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
# Copyright (c) 2018-2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
# Description of the test:
# This test runs the 'blogbench', and extracts the 'scores' for reads
# and writes
# Note - the scores are *not* normalised for the number of iterations run,
# they are total scores for all iterations (this is the blogbench default output)
set -e
# General env
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_PATH}/../lib/common.bash"
TEST_NAME="blogbench"
IMAGE="docker.io/library/local-blogbench:latest"
DOCKERFILE="${SCRIPT_PATH}/blogbench_dockerfile/Dockerfile"
# Number of iterations for blogbench to run - note, results are not
# scaled to iterations - more iterations results in bigger results
ITERATIONS="${ITERATIONS:-30}"
# Directory to run the test on
# This is run inside of the container
TESTDIR="${TESTDIR:-/tmp}"
CMD="blogbench -i ${ITERATIONS} -d ${TESTDIR}"
function main() {
# Check tools/commands dependencies
cmds=("awk" "docker")
init_env
check_cmds "${cmds[@]}"
check_ctr_images "${IMAGE}" "${DOCKERFILE}"
sudo systemctl restart containerd
metrics_json_init
info "Running Blogbench test"
local output=$(sudo -E ${CTR_EXE} run --rm --runtime=${CTR_RUNTIME} ${IMAGE} $(random_name) ${CMD})
# Save configuration
metrics_json_start_array
local frequency=$(echo "${output}" | grep "Frequency" | cut -d "=" -f2 | cut -d ' ' -f2)
local iterations=$(echo "${output}" | grep -w "iterations" | cut -d ' ' -f3)
local spawing_writers=$(echo "${output}" | grep -w "writers" | cut -d ' ' -f2)
local spawing_rewriters=$(echo "${output}" | grep -w "rewriters" | cut -d ' ' -f2)
local spawing_commenters=$(echo "${output}" | grep -w "commenters" | cut -d ' ' -f2)
local spawing_readers=$(echo "${output}" | grep -w "readers" | cut -d ' ' -f2)
local json="$(cat << EOF
{
"Frequency" : ${frequency},
"Iterations" : ${iterations},
"Number of spawing writers" : ${spawing_writers},
"Number of spawing rewriters" : ${spawing_rewriters},
"Number of spawing commenters" : ${spawing_commenters},
"Number of spawing readers" : ${spawing_readers}
}
EOF
)"
metrics_json_add_array_element "${json}"
metrics_json_end_array "Config"
# Save results
info "Saving Blogbench results"
metrics_json_start_array
local writes=$(tail -2 <<< "${output}" | head -1 | awk '{print $5}')
local reads=$(tail -1 <<< "${output}" | awk '{print $6}')
# Obtaining other Blogbench results
local -r data=$(echo "${output}" | tail -n +12 | head -n -3)
local nb_blogs=$(echo "${data}" | awk ' BEGIN {ORS="\t"} {print $1} ' | tr '\t' ',' | sed '$ s/.$//')
local r_articles=$(echo "${data}" | awk ' BEGIN {ORS="\t"} {print $2} ' | tr '\t' ',' | sed '$ s/.$//')
local w_articles=$(echo "${data}" | awk ' BEGIN {ORS="\t"} {print $3} ' | tr '\t' ',' | sed '$ s/.$//')
local r_pictures=$(echo "${data}" | awk ' BEGIN {ORS="\t"} {print $4} ' | tr '\t' ',' | sed '$ s/.$//')
local w_pictures=$(echo "${data}" | awk ' BEGIN {ORS="\t"} {print $5} ' | tr '\t' ',' | sed '$ s/.$//')
local r_comments=$(echo "${data}" | awk ' BEGIN {ORS="\t"} {print $6} ' | tr '\t' ',' | sed '$ s/.$//')
local w_comments=$(echo "${data}" | awk ' BEGIN {ORS="\t"} {print $7} ' | tr '\t' ',' | sed '$ s/.$//')
local json="$(cat << EOF
{
"write": {
"Result" : ${writes},
"Units" : "items"
},
"read": {
"Result" : ${reads},
"Units" : "items"
},
"Nb blogs": {
"Result" : "${nb_blogs}"
},
"R articles": {
"Result" : "${r_articles}"
},
"W articles": {
"Result" : "${w_articles}"
},
"R pictures": {
"Result" : "${r_pictures}"
},
"W pictures": {
"Result" : "${w_pictures}"
},
"R comments": {
"Result" : "${r_comments}"
},
"W comments": {
"Result" : "${w_comments}"
}
}
EOF
)"
metrics_json_add_array_element "${json}"
metrics_json_end_array "Results"
metrics_json_save
clean_env_ctr
}
main "$@"