Skip to content

Commit 3f6e198

Browse files
author
Pavel Kosov
committed
[LNT] Combine perf data metrics from several files
Metrics are recorded to files test.perf_data, test.perf_data1, … Parse all these files into a single dictionary. OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg Reviewed By: cmatthews Differential Revision: https://reviews.llvm.org/D114770
1 parent 44cd777 commit 3f6e198

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lnt/testing/profile/perf.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,33 @@
55

66
import os
77
import traceback
8+
import glob
89

910
try:
1011
from . import cPerf # type: ignore # mypy cannot process Cython modules
1112
except Exception:
1213
pass
1314

1415

16+
def merge_recursively(dct1, dct2):
17+
# type: (dict, dict) -> None
18+
"""Add the content of dct2 to dct1.
19+
:param dct1: merge to.
20+
:param dct2: merge from.
21+
"""
22+
for k, v in dct2.items():
23+
if k in dct1:
24+
if isinstance(dct1[k], dict) and isinstance(v, dict):
25+
merge_recursively(dct1[k], v)
26+
elif isinstance(dct1[k], list) and isinstance(v, list):
27+
dct1[k].extend(v)
28+
else:
29+
raise TypeError("Values for the key {} must be the same type (dict or list), "
30+
"but got {} and {}".format(k, type(dct1[k]), type(v)))
31+
else:
32+
dct1[k] = v
33+
34+
1535
class LinuxPerfProfile(ProfileImpl):
1636
def __init__(self):
1737
pass
@@ -31,7 +51,10 @@ def deserialize(f, objdump='objdump', propagateExceptions=False,
3151
return None
3252

3353
try:
34-
data = cPerf.importPerf(f, objdump, binaryCacheRoot)
54+
data = {}
55+
for fname in glob.glob("%s*" % f):
56+
cur_data = cPerf.importPerf(fname, objdump, binaryCacheRoot)
57+
merge_recursively(data, cur_data)
3558

3659
# Go through the data and convert counter values to percentages.
3760
for f in data['functions'].values():

0 commit comments

Comments
 (0)