Skip to content

Commit a4639a9

Browse files
committed
[llvm-zorg][lldb-statistic] Submit statistics to LNT
Mimicks `submit-debuginfo-statistics-to-lnt.py` but for the `lldb-statistic` job.
1 parent 914a5b4 commit a4639a9

File tree

2 files changed

+79
-14
lines changed

2 files changed

+79
-14
lines changed

zorg/jenkins/jobs/jobs/lldb-statistics

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,22 @@ pipeline {
179179
}
180180
}
181181

182-
// TODO: for now we just dump the statistics to the console.
183-
//stage('Submit debuginfo statistics to LNT') {
184-
// steps {
185-
// sh '''
186-
// source ./venv/bin/activate
182+
stage('Submit statistics to LNT') {
183+
steps {
184+
sh '''
185+
source ./venv/bin/activate
187186
188-
// cd src/clang-13
189-
// git tag -a -m "First Commit" first_commit 97724f18c79c7cc81ced24239eb5e883bf1398ef || true
187+
cd src/clang-13
188+
git tag -a -m "First Commit" first_commit 97724f18c79c7cc81ced24239eb5e883bf1398ef || true
190189
191-
// git_desc=$(git describe --match "first_commit")
192-
// export GIT_DISTANCE=$(echo ${git_desc} | cut -f 2 -d "-")
190+
git_desc=$(git describe --match "first_commit")
191+
export GIT_DISTANCE=$(echo ${git_desc} | cut -f 2 -d "-")
193192
194-
// cd -
193+
cd -
195194
196-
// python llvm-zorg/zorg/jenkins/jobs/util/submit-debuginfo-statistics-to-lnt.py
197-
// '''
198-
// }
199-
//}
195+
python llvm-zorg/zorg/jenkins/jobs/util/submit-debuginfo-statistics-to-lnt.py /tmp/lldb-metrics/results
196+
'''
197+
}
198+
}
200199
}
201200
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import datetime
2+
import requests
3+
import json
4+
import pprint
5+
import time
6+
import os
7+
import sys
8+
9+
# Note there are fewer git commits in the monorepo than there were svn revisions.
10+
#LLVM_REV=os.environ["GIT_DISTANCE"]
11+
#JOB_NAME=f'{os.environ["NODE_NAME"]}_{os.environ["JOB_NAME"]}'
12+
13+
if len(sys.argv) != 2:
14+
print("Usage: submit-lldb-statistics-to-lnt.py <path/to/stats/directory>")
15+
sys.exit(1)
16+
17+
LLDB_STATS_PATH=sys.argv[1]
18+
19+
_data = {}
20+
for filename in os.listdir(LLDB_STATS_PATH):
21+
if not filename.endswith(".json"):
22+
continue
23+
24+
json_path = os.path.join(LLDB_STATS_PATH, filename)
25+
with open(json_path, 'r') as f:
26+
# Test-case is the filename without the extension
27+
testcase_name = os.path.splitext(filename)[0]
28+
_data[testcase_name] = json.load(f)
29+
30+
if len(_data) == 0:
31+
print("Empty data...exiting.")
32+
sys.exit(1)
33+
34+
# For each test-case, create a separate LNT entry
35+
# (so we can compare statistics per test-case over time).
36+
for testcase_name, stats in _data.items():
37+
run_infos = {
38+
"end_time": datetime.datetime.now().isoformat(),
39+
"start_time": datetime.datetime.now().isoformat(),
40+
"llvm_project_revision":LLVM_REV,
41+
}
42+
43+
to_send = {
44+
"format_name": 'json',
45+
"format_version": "2",
46+
"machine": {
47+
"name": "%s_%s-v1"%(testcase_name, JOB_NAME),
48+
},
49+
"run": run_infos,
50+
"tests": stats
51+
}
52+
to_send = {
53+
"merge": "replace",
54+
'format_name': 'json',
55+
'input_data': json.dumps(to_send),
56+
'commit': "1", # compatibility with old servers.
57+
}
58+
59+
60+
pprint.pprint(to_send)
61+
try:
62+
requests.post("http://104.154.54.203/db_default/v4/nts/submitRun", data=to_send).raise_for_status()
63+
except:
64+
time.sleep(10)
65+
print("Sleeping because of error.")
66+
requests.post("http://104.154.54.203/db_default/v4/nts/submitRun", data=to_send).raise_for_status()

0 commit comments

Comments
 (0)