Skip to content

Commit 3f31401

Browse files
committed
Make measurement of instruction count configurable
1 parent f55c32d commit 3f31401

File tree

8 files changed

+51
-11
lines changed

8 files changed

+51
-11
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ENV PHPIZE_DEPS \
2222
pkg-config \
2323
re2c \
2424
bison \
25-
valgrind
25+
valgrind-devel
2626

2727
# persistent / runtime deps
2828
RUN set -eux; \

bin/benchmark.sh

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ EOF
125125
}
126126

127127
print_result_tsv_header () {
128-
printf "Test name\tTest warmup\tTest iterations\tTest requests\tPHP\tPHP Commit hash\tPHP Commit URL\tMin\tMax\tStd dev\tAverage\tAverage diff %%\tMedian\tMedian diff %%\tInstruction count\n\tMemory usage\n" >> "$1.tsv"
128+
if [ "$INFRA_INSTRUCTION_COUNT" == "1" ]; then
129+
instruction_count_header_name="\tInstruction count"
130+
else
131+
instruction_count_header_name=""
132+
fi
133+
134+
printf "Test name\tTest warmup\tTest iterations\tTest requests\tPHP\tPHP Commit hash\tPHP Commit URL\tMin\tMax\tStd dev\tAverage\tAverage diff %%\tMedian\tMedian diff %%$instruction_count_header_name\tMemory usage\n" >> "$1.tsv"
129135
}
130136

131137
print_result_md_header () {
@@ -134,11 +140,19 @@ print_result_md_header () {
134140
description="$description, $TEST_REQUESTS requests"
135141
fi
136142

143+
if [ "$INFRA_INSTRUCTION_COUNT" == "1" ]; then
144+
instruction_count_header_name="| Instr count "
145+
instruction_count_header_separator="|---------------";
146+
else
147+
instruction_count_header_name=""
148+
instruction_count_header_separator="";
149+
fi
150+
137151
cat << EOF >> "$1.md"
138152
### $TEST_NAME - $description (sec)
139153
140-
| PHP | Min | Max | Std dev | Average | Average diff % | Median | Median diff % | Instr count | Memory |
141-
|-------------|-------------|-------------|--------------|------------|-----------------|------------|---------------|---------------|---------------|
154+
| PHP | Min | Max | Std dev | Average | Average diff % | Median | Median diff % $instruction_count_header_name| Memory |
155+
|-------------|-------------|-------------|--------------|------------|-----------------|------------|---------------$instruction_count_header_separator|---------------|
142156
EOF
143157
}
144158

@@ -148,7 +162,15 @@ print_result_value () {
148162
url="${PHP_REPO//.git/}/commit/$commit_hash"
149163

150164
results="$(cat "$1")"
151-
instruction_count="$(cat "$2")"
165+
if [ "$INFRA_INSTRUCTION_COUNT" == "1" ]; then
166+
instruction_count_tsv_format="\t%d"
167+
instruction_count_md_format="|%d"
168+
instruction_count="$(cat "$2")"
169+
else
170+
instruction_count_tsv_format="%s"
171+
instruction_count_md_format="%s"
172+
instruction_count=""
173+
fi
152174
memory_result="$(cat "$3")"
153175

154176
min="$(min "$results")"
@@ -166,13 +188,13 @@ print_result_value () {
166188
std_dev="$(std_deviation "$results")"
167189
memory_usage="$(echo "scale=3;${memory_result}/1024"|bc -l)"
168190

169-
printf "%s\t%d\t%d\t%d\t%s\t%s\t%s\t%.5f\t%.5f\t%.5f\t%.5f\t%.2f\t%.5f\t%.2f\t%d\t%.2f\n" \
191+
printf "%s\t%d\t%d\t%d\t%s\t%s\t%s\t%.5f\t%.5f\t%.5f\t%.5f\t%.2f\t%.5f\t%.2f$instruction_count_tsv_format\t%.2f\n" \
170192
"$TEST_NAME" "$TEST_WARMUP" "$TEST_ITERATIONS" "$TEST_REQUESTS" \
171193
"$PHP_NAME" "$commit_hash" "$url" \
172194
"$min" "$max" "$std_dev" "$average" "$average_diff" "$median" "$median_diff" "$instruction_count" "$memory_usage" >> "$4.tsv"
173195

174196
if [ "$5" -eq "1" ]; then
175-
printf "|[%s]($url)|%.5f|%.5f|%.5f|%.5f|%.2f%%|%.5f|%.2f%%|%d|%.2f MB|\n" \
197+
printf "|[%s]($url)|%.5f|%.5f|%.5f|%.5f|%.2f%%|%.5f|%.2f%%$instruction_count_md_format|%.2f MB|\n" \
176198
"$PHP_NAME" "$min" "$max" "$std_dev" "$average" "$average_diff" "$median" "$median_diff" "$instruction_count" "$memory_usage" >> "$4.md"
177199
fi
178200
}
@@ -258,13 +280,17 @@ format_memory_log_file() {
258280
run_real_benchmark () {
259281
# Benchmark
260282
run_cgi "verbose" "0" "1" "$1" "$2" "$3"
261-
run_cgi "instruction_count" "10" "10" "$1" "$2" "$3" 2>&1 | tee -a "$instruction_count_log_file"
283+
if [ "$INFRA_INSTRUCTION_COUNT" == "1" ]; then
284+
run_cgi "instruction_count" "10" "10" "$1" "$2" "$3" 2>&1 | tee -a "$instruction_count_log_file"
285+
fi
262286
run_cgi "memory" "$TEST_WARMUP" "$TEST_REQUESTS" "$1" "$2" "$3" 2>&1 | tee -a "$memory_log_file"
263287
for b in $(seq $TEST_ITERATIONS); do
264288
run_cgi "quiet" "$TEST_WARMUP" "$TEST_REQUESTS" "$1" "$2" "$3" 2>&1 | tee -a "$log_file"
265289
done
266290

267-
format_instruction_count_log_file "$instruction_count_log_file"
291+
if [ "$INFRA_INSTRUCTION_COUNT" == "1" ]; then
292+
format_instruction_count_log_file "$instruction_count_log_file"
293+
fi
268294
format_memory_log_file "$memory_log_file"
269295

270296
# Format log
@@ -276,11 +302,15 @@ run_real_benchmark () {
276302

277303
run_micro_benchmark () {
278304
# Benchmark
279-
run_cgi "instruction_count" "2" "2" "$1" "" "" 2>&1 | tee -a "$instruction_count_log_file"
305+
if [ "$INFRA_INSTRUCTION_COUNT" == "1" ]; then
306+
run_cgi "instruction_count" "2" "2" "$1" "" "" 2>&1 | tee -a "$instruction_count_log_file"
307+
fi
280308
run_cgi "memory" "0" "$TEST_WARMUP" "$1" "" "" 2>&1 | tee -a "$memory_log_file"
281309
run_cgi "normal" "$TEST_WARMUP" "$TEST_ITERATIONS" "$1" "" "" 2>&1 | tee -a "$log_file"
282310

283-
format_instruction_count_log_file "$instruction_count_log_file"
311+
if [ "$INFRA_INSTRUCTION_COUNT" == "1" ]; then
312+
format_instruction_count_log_file "$instruction_count_log_file"
313+
fi
284314
format_memory_log_file "$memory_log_file"
285315

286316
# Format log

build/infrastructure/aws/generate_aws_config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ infra_id = "$INFRA_ID"
5353
infra_name = "$INFRA_NAME"
5454
environment = "$INFRA_ENVIRONMENT"
5555
runner = "$INFRA_RUNNER"
56+
measure_instruction_count = "$INFRA_MEASURE_INSTRUCTION_COUNT"
5657
docker_registry = "$INFRA_DOCKER_REGISTRY"
5758
docker_repository = "$INFRA_DOCKER_REPOSITORY"
5859
EOF

build/infrastructure/aws/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ EOF
109109
"export INFRA_ARCHITECTURE=\"${var.image_architecture}\"",
110110
"export INFRA_ENVIRONMENT=\"${var.environment}\"",
111111
"export INFRA_RUNNER=\"${var.runner}\"",
112+
"export INFRA_MEASURE_INSTRUCTION_COUNT=\"${var.measure_instruction_count}\"",
112113
"export INFRA_DOCKER_REGISTRY=\"${var.docker_registry}\"",
113114
"export INFRA_DOCKER_REPOSITORY=\"${var.docker_repository}\"",
114115

@@ -147,6 +148,7 @@ EOF
147148
"export INFRA_ARCHITECTURE=\"${var.image_architecture}\"",
148149
"export INFRA_ENVIRONMENT=\"${var.environment}\"",
149150
"export INFRA_RUNNER=\"${var.runner}\"",
151+
"export INFRA_MEASURE_INSTRUCTION_COUNT=\"${var.measure_instruction_count}\"",
150152
"export INFRA_DOCKER_REGISTRY=\"${var.docker_registry}\"",
151153
"export INFRA_DOCKER_REPOSITORY=\"${var.docker_repository}\"",
152154

build/infrastructure/aws/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ variable "runner" {
115115
type = string
116116
}
117117

118+
variable "measure_instruction_count" {
119+
type = string
120+
}
121+
118122
variable "docker_registry" {
119123
type = string
120124
sensitive = false

config/infra/aws/arm64.ini.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ INFRA_DISABLE_TURBO_BOOST=0
88
INFRA_DISABLE_HYPER_THREADING=0
99

1010
INFRA_RUNNER=host
11+
INFRA_MEASURE_INSTRUCTION_COUNT=0
1112
INFRA_DOCKER_REGISTRY=
1213
INFRA_DOCKER_REPOSITORY=

config/infra/aws/x86_64-metal.ini.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ INFRA_DISABLE_TURBO_BOOST=1
88
INFRA_DISABLE_HYPER_THREADING=1
99

1010
INFRA_RUNNER=host
11+
INFRA_MEASURE_INSTRUCTION_COUNT=0
1112
INFRA_DOCKER_REGISTRY=public.ecr.aws/abcdefgh
1213
INFRA_DOCKER_REPOSITORY=php-cgi

config/infra/aws/x86_64.ini.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ INFRA_DISABLE_TURBO_BOOST=0
88
INFRA_DISABLE_HYPER_THREADING=1
99

1010
INFRA_RUNNER=host
11+
INFRA_MEASURE_INSTRUCTION_COUNT=0
1112
INFRA_DOCKER_REGISTRY=public.ecr.aws/abcdefgh
1213
INFRA_DOCKER_REPOSITORY=php-cgi

0 commit comments

Comments
 (0)