Skip to content

Commit 64dbe2c

Browse files
authored
Bench unit test compile time (rust-lang#943)
* bench unit test compile time
1 parent 6465118 commit 64dbe2c

File tree

3 files changed

+98
-3
lines changed

3 files changed

+98
-3
lines changed

.github/workflows/enzyme-ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Enzyme CI
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
48

59
jobs:
610
build-linux:
@@ -51,7 +55,10 @@ jobs:
5155
- name: make check-activityanalysis
5256
run: cd enzyme/build && make check-activityanalysis -j`nproc`
5357
- name: make check-enzyme
54-
run: cd enzyme/build && make check-enzyme -j`nproc`
58+
run: cd enzyme/build && make check-enzyme-bench -j`nproc`
59+
- name: graph results
60+
run: python3 enzyme/test/upload-results.py enzyme/build/test/Enzyme/results.json --url https://enzyme.mit.edu/cibench/api --token ${{ secrets.GRAPH_TOKEN }}
61+
if: github.event_name != 'pull_request' && matrix.build == 'Release'
5562

5663
build-macos:
5764
name: Enzyme CI LLVM ${{ matrix.llvm }} ${{ matrix.build }} macOS
@@ -86,7 +93,10 @@ jobs:
8693
- name: make check-activityanalysis
8794
run: cd enzyme/build && make check-activityanalysis -j 3
8895
- name: make check-enzyme
89-
run: cd enzyme/build && make check-enzyme -j 3
96+
run: cd enzyme/build && make check-enzyme-bench -j 3
97+
- name: graph results
98+
run: python3 enzyme/test/upload-results.py enzyme/build/test/Enzyme/results.json --url https://enzyme.mit.edu/cibench/api --token ${{ secrets.GRAPH_TOKEN }}
99+
if: github.event_name != 'pull_request' && matrix.build == 'Release'
90100

91101
build-xcode:
92102
name: Enzyme CI LLVM ${{ matrix.llvm }} ${{ matrix.build }} macOS XCode

enzyme/test/Enzyme/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ add_lit_testsuite(check-enzyme "Running enzyme regression tests"
1212
ARGS -v
1313
)
1414

15+
add_lit_testsuite(check-enzyme-bench "Benchmarking enzyme regression tests"
16+
${CMAKE_CURRENT_BINARY_DIR}
17+
DEPENDS ${ENZYME_TEST_DEPS}
18+
ARGS -v --time-tests -o results.json
19+
)
20+
21+
1522
set_target_properties(check-enzyme PROPERTIES FOLDER "Tests")
23+
set_target_properties(check-enzyme-bench PROPERTIES FOLDER "Tests")

enzyme/test/upload-results.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import json
2+
import datetime
3+
import subprocess
4+
import requests
5+
import argparse
6+
import platform
7+
8+
9+
def get_git_revision_hash():
10+
try:
11+
return subprocess.check_output(['git', 'rev-parse', 'HEAD'], stderr=subprocess.STDOUT).decode('ascii').strip()
12+
except:
13+
return "N/A"
14+
15+
16+
def get_git_revision_date():
17+
try:
18+
time = subprocess.check_output(
19+
['git', 'show', '--quiet', '--format=%ct', 'HEAD'], stderr=subprocess.STDOUT).decode('ascii').strip()
20+
dt = datetime.datetime.fromtimestamp(
21+
int(time), tz=datetime.timezone.utc)
22+
return dt
23+
except:
24+
return datetime.datetime.now(datetime.timezone.utc)
25+
26+
27+
def extract_results(json):
28+
result = []
29+
githash = get_git_revision_hash()
30+
time = get_git_revision_date().isoformat()
31+
arch = platform.platform()
32+
llvm = ".".join(str(json["__version__"]))
33+
34+
for test in json["tests"]:
35+
if test["code"] == "PASS":
36+
compiletime = test["elapsed"]
37+
name = test["name"]
38+
pathstr = name.split(" :: ")[1]
39+
comps = pathstr.split("/")
40+
mode = comps[1]
41+
testname = ".".join(comps[2:])
42+
43+
res = {
44+
"mode": mode,
45+
"llvm-version": llvm,
46+
"test-suite": "Enzyme Unit Tests",
47+
"commit": githash,
48+
"test-name": testname,
49+
"compile-time": compiletime,
50+
"timestamp": time,
51+
"platform": arch
52+
}
53+
result.append(res)
54+
55+
return result
56+
57+
58+
parser = argparse.ArgumentParser()
59+
parser.add_argument('file', type=argparse.FileType(
60+
'r'), help="JSON file containing the benchmark results")
61+
parser.add_argument('-t', '--token', type=str, required=False,
62+
help="Token to authorize at graphing backend")
63+
parser.add_argument('-u', '--url', type=str, required=True,
64+
help="URL of the graphing backend")
65+
66+
args = parser.parse_args()
67+
68+
json = json.load(args.file)
69+
results = extract_results(json)
70+
71+
if args.token:
72+
response = requests.post(args.url, json=results,
73+
headers={"X-TOKEN": args.token})
74+
response.raise_for_status()
75+
else:
76+
response = requests.post(args.url, json=results)
77+
response.raise_for_status()

0 commit comments

Comments
 (0)