-
Notifications
You must be signed in to change notification settings - Fork 0
/
measure.sh
executable file
·114 lines (94 loc) · 3.63 KB
/
measure.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
#!/bin/sh
set -o errexit
url=http://localhost:8001/api/v1/namespaces/monitoring/services/monitoring-kube-prometheus-prometheus:http-web/proxy/api/v1/query
trap 'jobs -p | xargs -r kill -TERM' INT TERM EXIT HUP
# open the proxy in the background
kubectl proxy --port=8001 &
# Query helpers
percentile() {
echo "histogram_quantile($1, $2)"
}
stddev() {
echo "stddev_over_time(($1)[3m:])"
}
run_query() {
until result=$(curl -s $url -d "query=$1" | jq '.data.result[0].value[1] | tonumber')
do
echo "Failed to query, retrying..."
sleep 5
done
result=$(echo "$result" | awk '{ printf("%.3f",$1) }')
echo "$result"
}
wait_for_query_value() {
result=0
until [ "$result" -eq 1 ]
do
sleep 10
limitOfRetries=0
value=$(curl -s $url -d "query=$1" | jq ' try .data.result[0].value[1] | tonumber')
until [ ! -z "$value" ]
do
# tries to query the endpoint for a maximum of 5 minutes
if [ $limitOfRetries -eq 30 ]
then
echo "Error querying endpoint $url"
exit 1
fi
echo "Failed to query to endpoint $url, retrying..."
sleep 10
value=$(curl -s $url -d "query=$1" | jq 'try .data.result[0].value[1] | tonumber')
((limitOfRetries=limitOfRetries+1))
done
result=$(echo "$value $2 $3" | bc)
printf "\r %g %s %g: %s" "$value" "$2" "$3" "$result"
done
printf "\n"
}
# Query definitions
latency="sum by (le) (rate(zeebe_process_instance_execution_time_bucket{namespace=\"$BENCHMARK_NAME\"}[3m]))"
throughput="sum(rate(zeebe_element_instance_events_total{namespace=\"$BENCHMARK_NAME\", action=\"completed\", type=\"PROCESS\"}[3m]))"
# Wait until metrics are stable
start_time=$(date +%s%3N)
stable_latency="$(stddev "$(percentile 0.99 "$latency")")"
stable_throughput="$(stddev "$throughput")"
echo "Waiting for minimal throughput"
wait_for_query_value "$throughput" \> 5
echo "Waiting for stable process instance execution times (stddev < 0.5)"
wait_for_query_value "$stable_latency" \< 0.5
echo "Waiting for stable throughput (stddev < 0.5)"
wait_for_query_value "$stable_throughput" \< 0.5
# Measure
process_latency_99=$(run_query "$(percentile 0.99 "$latency")")
process_latency_90=$(run_query "$(percentile 0.90 "$latency")")
process_latency_50=$(run_query "$(percentile 0.50 "$latency")")
throughput_avg=$(run_query "$throughput")
end_time=$(date +%s%3N)
grafana_url="https://grafana.dev.zeebe.io/d/zeebe-dashboard/zeebe?orgId=1&var-namespace=$BENCHMARK_NAME&from=$start_time&to=$end_time"
if [ -n "$GITHUB_STEP_SUMMARY" ]
then
{
echo "**Process Instance Execution Time**: p99=$process_latency_99 p90=$process_latency_90 p50=$process_latency_50"
echo "**Throughput**: $throughput_avg PI/s"
echo "[Grafana Dashboard]($grafana_url)"
} >> "$GITHUB_STEP_SUMMARY"
fi
if [ -n "$GITHUB_OUTPUT" ]
then
{
echo "summary_markdown<<EOF"
echo "**Process Instance Execution Time**: p99=$process_latency_99 p90=$process_latency_90 p50=$process_latency_50"
echo "**Throughput**: $throughput_avg PI/s"
echo "[Grafana]($grafana_url)"
echo "EOF"
} >> "$GITHUB_OUTPUT"
{
echo "summary_slack<<EOF"
echo "*Process Instance Execution Time*: p99=$process_latency_99 p90=$process_latency_90 p50=$process_latency_50"
echo "*Throughput*: $throughput_avg PI/s"
echo "<$grafana_url|Grafana>"
echo "EOF"
} >> "$GITHUB_OUTPUT"
fi
echo "Process Instance Execution Time: p99=$process_latency_99 p90=$process_latency_90 p50=$process_latency_50"
echo "Throughput: $throughput_avg PI/s"