-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (147 loc) · 7.62 KB
/
benchmark.yaml
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
on:
workflow_call:
inputs:
runs-on-hosted:
type: string
description: Whether to use self or GitHub hosted runners, either use ubuntu-latest for GitHub hosted or self-hosted
runs-on-architecture:
type: string
description: The architecture to use, either x64, amd64 or arm64
default: ''
run-name:
type: string
description: The name to use for the run
jobs:
run:
runs-on: ${{ inputs.runs-on-hosted == 'self-hosted' && fromJson(format('[''{0}'', ''{1}'']', inputs.runs-on-hosted, inputs.runs-on-architecture)) || inputs.runs-on-hosted }}
env:
RUN_NAME: ${{ inputs.run-name }}
steps:
- run: sudo apt-get update
if: ${{ always() && !cancelled() }}
- name: Network speed test
if: ${{ always() && !cancelled() }}
id: network-speed-test
run: |
wget https://github.com/librespeed/speedtest-cli/releases/download/v1.0.10/librespeed-cli_1.0.10_linux_$(dpkg --print-architecture).tar.gz
tar -xvzf librespeed-cli_1.0.10_linux_$(dpkg --print-architecture).tar.gz
echo "---network speed test start---"
./librespeed-cli --json > speedtest-result.json
sleep 1
echo "ping=$(cat speedtest-result.json | jq '.[0].ping')" >> $GITHUB_OUTPUT
echo "jitter=$(cat speedtest-result.json | jq '.[0].jitter')" >> $GITHUB_OUTPUT
echo "upload=$(cat speedtest-result.json | jq '.[0].upload')" >> $GITHUB_OUTPUT
echo "download=$(cat speedtest-result.json | jq '.[0].download')" >> $GITHUB_OUTPUT
rm speedtest-result.json librespeed-cli librespeed-cli_1.0.10_linux_$(dpkg --print-architecture).tar.gz
- name: Download charmhub resource test
if: ${{ always() && !cancelled() }}
id: charmhub-resource-download
run: |
python3 -c 'from urllib.request import Request, urlopen; from pathlib import Path; Path("image_location.json").write_bytes(urlopen("https://api.charmhub.io/api/v1/resources/download/charm_18zuSzvljyQo6mJMWjcjN2nMm1TiWKCF.indico-image_179").read())'
export INDICO_IMAGE_NAME=($(jq -r '.ImageName' image_location.json))
export CHARMHUB_REGISTRY_USERNAME=($(jq -r '.Username' image_location.json))
export CHARMHUB_REGISTRY_PASSWORD=($(jq -r '.Password' image_location.json))
sudo apt-get -y install skopeo
sudo skopeo login registry.jujucharms.com -u $CHARMHUB_REGISTRY_USERNAME -p $CHARMHUB_REGISTRY_PASSWORD
for ((i=0; i<5; i++)); do
/usr/bin/time -o temp_time.txt -f %e sudo skopeo copy docker://$INDICO_IMAGE_NAME docker-archive:./indico_image.tar
cat temp_time.txt >> time.txt
rm -f ./indico_image.tar temp_time.txt
done
sleep 1
python3 -c "import pathlib; import statistics; (pathlib.Path() / 'mean_time.txt').write_text(str(statistics.mean(map(float, (pathlib.Path() / 'time.txt').read_text().splitlines()))))"
python3 -c "import pathlib; import statistics; (pathlib.Path() / 'min_time.txt').write_text(str(min(map(float, (pathlib.Path() / 'time.txt').read_text().splitlines()))))"
python3 -c "import pathlib; import statistics; (pathlib.Path() / 'max_time.txt').write_text(str(max(map(float, (pathlib.Path() / 'time.txt').read_text().splitlines()))))"
cat mean_time.txt
cat min_time.txt
cat max_time.txt
echo "mean=$(cat mean_time.txt)" >> $GITHUB_OUTPUT
echo "min=$(cat min_time.txt)" >> $GITHUB_OUTPUT
echo "max=$(cat max_time.txt)" >> $GITHUB_OUTPUT
rm time.txt mean_time.txt min_time.txt max_time.txt
- name: Checkout GitHub pages
uses: actions/checkout@v4
if: ${{ always() && !cancelled() }}
with:
ref: gh-pages
- name: prepare dir
if: ${{ always() && !cancelled() }}
run: |
mkdir -p results/v1/
test -f results/v1/$RUN_NAME.csv || echo "time,network speed test ping (s),jitter (s),upload (bit/s),download (bit/s),charmhub resource download mean (s),min (s),max (s)," > results/v1/$RUN_NAME.csv
- name: Write results
if: ${{ always() && !cancelled() }}
env:
NETWORK_SPEED_TEST_PING: ${{ steps.network-speed-test.outputs.ping }}
NETWORK_SPEED_TEST_JITTER: ${{ steps.network-speed-test.outputs.jitter }}
NETWORK_SPEED_TEST_UPLOAD: ${{ steps.network-speed-test.outputs.upload }}
NETWORK_SPEED_TEST_DOWNLOAD: ${{ steps.network-speed-test.outputs.download }}
CHARMHUB_RESOURCE_DOWNLOAD_MEAN: ${{ steps.charmhub-resource-download.outputs.mean }}
CHARMHUB_RESOURCE_DOWNLOAD_MIN: ${{ steps.charmhub-resource-download.outputs.min }}
CHARMHUB_RESOURCE_DOWNLOAD_MAX: ${{ steps.charmhub-resource-download.outputs.max }}
run: |
echo $(TZ=UTC date +"%Y-%m-%dT%H:%M:%S%z"),$NETWORK_SPEED_TEST_PING,$NETWORK_SPEED_TEST_JITTER,$NETWORK_SPEED_TEST_UPLOAD,$NETWORK_SPEED_TEST_DOWNLOAD,$CHARMHUB_RESOURCE_DOWNLOAD_MEAN,$CHARMHUB_RESOURCE_DOWNLOAD_MIN,$CHARMHUB_RESOURCE_DOWNLOAD_MAX, >> results/v1/$RUN_NAME.csv
- name: Create charts
if: ${{ always() && !cancelled() }}
run: |
sudo apt install -y python3-venv
python3 -m venv .venv
source .venv/bin/activate
pip install matplotlib pandas
echo '
import datetime
import os
from matplotlib import pyplot as plt
import pandas as pd
import pytz
run_name = os.getenv("RUN_NAME")
my_data = pd.read_csv(f"results/v1/{run_name}.csv")
my_data["time"] = pd.to_datetime(my_data["time"])
my_data = my_data[my_data.time >= pd.to_datetime(datetime.datetime.now().replace(tzinfo=pytz.UTC) - datetime.timedelta(days=7))]
plt.subplot(2, 3, 1)
plt.plot(my_data["time"], my_data["network speed test ping (s)"])
plt.title("Network Speed Test Ping")
plt.xlabel("time")
plt.ylabel("milliseconds")
plt.xticks(rotation=30)
plt.subplot(2, 3, 2)
plt.plot(my_data["time"], my_data["jitter (s)"])
plt.title("Jitter")
plt.xlabel("time")
plt.ylabel("milliseconds")
plt.xticks(rotation=30)
plt.subplot(2, 3, 3)
plt.plot(my_data["time"], my_data["upload (bit/s)"], label="upload")
plt.plot(my_data["time"], my_data["download (bit/s)"], label="download")
plt.legend()
plt.title("Speed")
plt.xlabel("time")
plt.ylabel("MBit/s")
plt.xticks(rotation=30)
plt.subplot(2, 1, 2)
plt.plot(my_data["time"], my_data["max (s)"], label="max")
plt.plot(my_data["time"], my_data["charmhub resource download mean (s)"], label="mean")
plt.plot(my_data["time"], my_data["min (s)"], label="min")
plt.legend()
plt.title("Charmhub Resource Download")
plt.xlabel("time")
plt.ylabel("seconds")
fig = plt.gcf()
fig.set_figwidth(1.5 * 16)
fig.set_figheight(1.5 * 9)
plt.savefig(f"results/v1/{run_name}.png")
' > create_chart.py
python create_chart.py
deactivate
rm -rf .venv
rm create_chart.py
- name: Upload csv
uses: actions/upload-artifact@v4
with:
name: ${{ format('{0}-csv', inputs.run-name) }}
path: ${{ format('results/v1/{0}.csv', inputs.run-name) }}
- name: Upload png
uses: actions/upload-artifact@v4
with:
name: ${{ format('{0}-png', inputs.run-name) }}
path: ${{ format('results/v1/{0}.png', inputs.run-name) }}