-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2.compare.py
137 lines (104 loc) · 3.59 KB
/
2.compare.py
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
import os
import pandas as pd
from config.date import Ldate
path = "Version/"
data = []
fTASK = lambda x: tuple([int(i) for i in x.split(".")])
TASK = sorted(
[
i for i in os.listdir(path)
if "3." in i and os.path.exists(f"{path}{i}/py{i}.log")
], key=fTASK
)
print(TASK)
for t in TASK:
t1, t2, tdata = "", "", {}
with open(f"{path}{t}/py{t}.log") as f:
for i in f:
i = i.strip("\n")
if i.startswith("###"):
t1 = i.replace("###", "").replace(" ", "")
if i.startswith("Mean"):
t2 = i.replace("Mean +- std dev: ", "")
tdata[t1] = t2
t1, t2 = "", ""
tdata = pd.DataFrame(
[[_k, _v] for _k, _v in tdata.items()],
columns=["Task", t]
)
data.append(tdata)
sdata = pd.DataFrame()
for tdata in data:
if len(sdata) == 0:
sdata = tdata
else:
sdata = pd.merge(sdata, tdata, on="Task", how="outer")
def fchange(string):
if pd.isna(string):
return string
string = str(string).split("+-")[0]
result = -999999
if "sec" in string:
result = float(string.replace("sec", ""))*1000
elif "ms" in string:
result = float(string.replace("ms", ""))
elif "us" in string:
result = float(string.replace("us", ""))/1000
elif "ns" in string:
result = float(string.replace("ns", ""))/1000/1000
return round(result, 4)
def change(df):
_df = df[df["Task"] != "pprint_safe_repr"].copy()
for icol in TASK:
_df[icol] = _df[icol].apply(fchange)
return _df
cdata = change(sdata)
cdata0 = cdata.copy()
cdata.loc["SUM"] = [""] + [round(cdata0[icol].sum(), 4) for icol in TASK]
cdata.loc["AVG"] = [""] + [round(cdata0[icol].mean(), 4) for icol in TASK]
_max = max([cdata0[icol].sum() for icol in TASK])
cdata.loc["UP%"] = [""] + [f"{_max/cdata0[icol].sum():.4%}" for icol in TASK]
Lup = cdata[cdata.index == "UP%"].to_dict()
FIRST = """
### 0.Readme
#### (1) Python Versions
> https://www.python.org/downloads/
#### (2) Running Environment
* Docker gcc library/gcc
> ecs.u1-c1m2.large/aliyun Intel(R) Xeon(R) Platinum 2核(vCPU) 4 GiB Ubuntu 22.04 64位
#### (3) Test Software
* [Pyperformance](https://github.com/python/pyperformance)
"""
END = """
<div align=center>
[![IvanaXu/PythonVersions](https://gitee.com/IvanaXu/PythonVersions/widgets/widget_card.svg?colors=4183c4,ffffff,ffffff,e3e9ed,666666,9b9b9b)](https://gitee.com/IvanaXu/PythonVersions)
https://github.com/IvanaXu/PythonVersions
</div>
"""
with open("README.md", "w") as f:
f.write(FIRST)
f.write("### 1.Versions\n")
idf = pd.DataFrame(TASK, columns=["version"])
idf["date"] = idf["version"].apply(lambda x: Ldate.get(x, ""))
idf["UP%"] = idf["version"].apply(lambda x: Lup.get(x, {}).get("UP%", ""))
# TOP = 5
# idf["Rank"] = idf["UP%"].rank(ascending=False).apply(lambda x: max(TOP-int(x)+1, 0) * "🌹")
# idf["Rank"] = idf["UP%"].rank(ascending=True).apply(lambda x: int(x) * "+")
TOP = 1
print(idf)
idf["Progress"] = idf["UP%"].apply(lambda x: int((float(x[:-1]) - 99)/TOP) * ">")
idf["rank"] = idf["version"].apply(fTASK)
idf.sort_values("rank", inplace=True)
print(idf)
for i in idf[["version", "date", "UP%", "Progress"]].to_markdown(index=None):
f.write(i)
f.write("\n\n")
f.write("### 2.Details\n")
for i in sdata.fillna("/").to_markdown():
f.write(i)
f.write("\n\n")
f.write("### 3.Calculation(UNIT: ms)\n")
for i in cdata.fillna("/").to_markdown():
f.write(i)
f.write("\n\n")
f.write(END)