-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_index.py
69 lines (59 loc) · 2.19 KB
/
create_index.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
#!/usr/bin/env python3
import os, glob, os.path, re
from locale import getpreferredencoding
ENCODING = getpreferredencoding()
files = {"IVB" : "index/ivybridge.html",
"CLX" : "index/cascadelake_server.html",
"IVT" : "index/ivytown.html",
"ICL" : "index/icelake.html",
"GLM" : "index/goldmont.html",
"SLM" : "index/silvermont.html",
"GLP" : "index/goldmontplus.html",
"BDW" : "index/broadwell.html",
"HSW" : "index/haswell.html",
"BDW-DE" : "index/broadwell_server.html",
"BDX" : "index/broadwell_server.html",
"BNL" : "index/atom.html",
"HSX" : "index/haswell_server.html",
"JKT" : "index/snbep.html",
"KNL" : "index/knl.html",
"KNM" : "index/knl.html",
"NHM-EP" : "index/corei7.html",
"NHM-EX" : "index/corei7b.html",
"WSM-EP-DP" : "index/corei7wdp.html",
"WSM-EP-SP" : "index/corei7wsp.html",
"WSM-EX" : "index/wsmex.html",
"SKL" : "index/skylake.html",
"SKX" : "index/skylake_server.html",
"SNB" : "index/snb.html",
"SNR" : "index/snr.html",
"ADL" : "index/adl.html"
}
outfile = "index.html"
out = open(outfile, "w")
out.write(""" <!DOCTYPE html>
<html>
<head>
<title>Performance Monitoring event lists for Intel processors</title>
</head>
<body>\n""")
for s in files:
p = files[s]
head = None
if p and os.access(p, os.R_OK):
with open(p, "rb") as fp:
data = ""
while len(data) < 5 or data[-5:] != "</h3>":
data += fp.read(1).decode(ENCODING)
m = re.search("<h3>(.*)</h3>", data)
if m:
head = m.group(1)
if p and head and s:
out.write("<h1><a href={}>{}</a></h1>\n".format(p, head))
folderfiles = sorted(glob.glob(os.path.join(s, "*.json")))
m = re.search(".*_([vV][\d\.]+).*\.json", folderfiles[-1])
if m:
folderfiles = sorted(glob.glob(os.path.join(s, "*{}*.json".format(m.group(1)))))
for f in folderfiles:
out.write("<p><a href={}>{}</a></p>\n\n".format(f, os.path.basename(f)))
out.write("""</body>\n</html>\n""")