Skip to content

Commit

Permalink
[llvm-zorg][lldb-statistic] Submit statistics to LNT
Browse files Browse the repository at this point in the history
Mimicks `submit-debuginfo-statistics-to-lnt.py` but
for the `lldb-statistic` job.
  • Loading branch information
Michael137 committed Oct 28, 2024
1 parent 914a5b4 commit a4639a9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 14 deletions.
27 changes: 13 additions & 14 deletions zorg/jenkins/jobs/jobs/lldb-statistics
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,22 @@ pipeline {
}
}

// TODO: for now we just dump the statistics to the console.
//stage('Submit debuginfo statistics to LNT') {
// steps {
// sh '''
// source ./venv/bin/activate
stage('Submit statistics to LNT') {
steps {
sh '''
source ./venv/bin/activate
// cd src/clang-13
// git tag -a -m "First Commit" first_commit 97724f18c79c7cc81ced24239eb5e883bf1398ef || true
cd src/clang-13
git tag -a -m "First Commit" first_commit 97724f18c79c7cc81ced24239eb5e883bf1398ef || true
// git_desc=$(git describe --match "first_commit")
// export GIT_DISTANCE=$(echo ${git_desc} | cut -f 2 -d "-")
git_desc=$(git describe --match "first_commit")
export GIT_DISTANCE=$(echo ${git_desc} | cut -f 2 -d "-")
// cd -
cd -
// python llvm-zorg/zorg/jenkins/jobs/util/submit-debuginfo-statistics-to-lnt.py
// '''
// }
//}
python llvm-zorg/zorg/jenkins/jobs/util/submit-debuginfo-statistics-to-lnt.py /tmp/lldb-metrics/results
'''
}
}
}
}
66 changes: 66 additions & 0 deletions zorg/jenkins/jobs/util/submit-lldb-statistics-to-lnt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import datetime
import requests
import json
import pprint
import time
import os
import sys

# Note there are fewer git commits in the monorepo than there were svn revisions.
#LLVM_REV=os.environ["GIT_DISTANCE"]
#JOB_NAME=f'{os.environ["NODE_NAME"]}_{os.environ["JOB_NAME"]}'

if len(sys.argv) != 2:
print("Usage: submit-lldb-statistics-to-lnt.py <path/to/stats/directory>")
sys.exit(1)

LLDB_STATS_PATH=sys.argv[1]

_data = {}
for filename in os.listdir(LLDB_STATS_PATH):
if not filename.endswith(".json"):
continue

json_path = os.path.join(LLDB_STATS_PATH, filename)
with open(json_path, 'r') as f:
# Test-case is the filename without the extension
testcase_name = os.path.splitext(filename)[0]
_data[testcase_name] = json.load(f)

if len(_data) == 0:
print("Empty data...exiting.")
sys.exit(1)

# For each test-case, create a separate LNT entry
# (so we can compare statistics per test-case over time).
for testcase_name, stats in _data.items():
run_infos = {
"end_time": datetime.datetime.now().isoformat(),
"start_time": datetime.datetime.now().isoformat(),
"llvm_project_revision":LLVM_REV,
}

to_send = {
"format_name": 'json',
"format_version": "2",
"machine": {
"name": "%s_%s-v1"%(testcase_name, JOB_NAME),
},
"run": run_infos,
"tests": stats
}
to_send = {
"merge": "replace",
'format_name': 'json',
'input_data': json.dumps(to_send),
'commit': "1", # compatibility with old servers.
}


pprint.pprint(to_send)
try:
requests.post("http://104.154.54.203/db_default/v4/nts/submitRun", data=to_send).raise_for_status()
except:
time.sleep(10)
print("Sleeping because of error.")
requests.post("http://104.154.54.203/db_default/v4/nts/submitRun", data=to_send).raise_for_status()

0 comments on commit a4639a9

Please sign in to comment.