forked from preshing/analyze-spec-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
make-graphs.py
executable file
·651 lines (575 loc) · 22.6 KB
/
make-graphs.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
#!/usr/bin/env python3
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import dict
from builtins import open
from builtins import round
from builtins import int
from future import standard_library
standard_library.install_aliases()
import collections
import csv
import datetime
import math
import re
import sys
from builtins import chr
from builtins import object
from builtins import range
from builtins import str
from contextlib import contextmanager
from functools import reduce
try:
import cairo
try:
import PIL.Image
except:
sys.stderr.write('PIL not installed. HQ antialiasing is disabled. Hint: `pip3 install pillow`\n')
except:
sys.stderr.write('Pycairo not installed. Writing .txt files only. Hint: `pip3 install pycairo`\n')
# ---------------------------------------------------------
# Helper functions
# ---------------------------------------------------------
def geometricAverage(values):
if len(values) == 0:
return 1
prod = reduce(lambda x, y: x * y, values)
return prod ** (1.0 / len(values))
def isWithinPercent(a, b, percent):
if a > b:
a, b = b, a # Make sure a is the smaller one
return b < a * (1 + percent / 100.0)
def monthDelta(loDate, hiDate):
return (hiDate.year * 12 + hiDate.month) - (loDate.year * 12 - loDate.month)
@contextmanager
def redirected_to_file(path):
save_stdout = sys.stdout
sys.stdout = open(path, 'w')
try:
yield None
finally:
sys.stdout = save_stdout
@contextmanager
def saved(cr):
cr.save()
try:
yield cr
finally:
cr.restore()
# ---------------------------------------------------------
# Determine CPU family & speed from name
# ---------------------------------------------------------
def extractMHzFromName(name):
m = re.search("(\\d+(?:\\.\\d+)?)a? ?([mg]hz)", name.lower())
value, units = m.groups()
value = float(value)
if units == 'ghz':
value *= 1000
return value
def identifyCPU(r):
# Remove cruft
cpu = r.cpu
for cruft in ['(TM)', '(R)', 'processor', 'Processor', '\xae', '\x99',
'supporting Hyper-Threading Technology',
'with Hyper-Threading Technology',
'with HT Technology',
'dual-core',
'Dual-Core',
'Quad-Core',
'Dual Core',
'Single Chip',
'w/ MMX technology',
'with MMX technology',
'with 2MB L2 Cache',
'64-bit',
'Model']:
cpu = cpu.replace(cruft, ' ')
cpu = re.sub('\\([^)]*\\)', ' ', cpu)
cpu = re.sub('/?\\d+(?:\\.\\d+)?[Aa]? ?[mMgG][hH][zZ]', ' ', cpu)
cpu = cpu.split(',')[0]
cpu = ' '.join(cpu.split())
# Identify brand and model
xeon = ' Xeon' if 'xeon' in cpu.lower() else ''
if 'Pentium III' in cpu or 'PentiumIII' in cpu:
return 'Intel Pentium', 'Pentium III' + xeon
if 'Pentium II' in cpu:
return 'Intel Pentium', 'Pentium II' + xeon
if xeon:
m = re.search('E7-[^\\s]+', cpu)
if m:
return 'Intel Xeon', 'Xeon ' + m.group()
m = re.search('E3-[^\\s]+', cpu)
if m:
return 'Intel Xeon', 'Xeon ' + m.group()
m = re.search('[A-Z]?(\\d)\\d{3}[A-Z]?', cpu)
if m:
return 'Intel Xeon', 'Xeon ' + m.group()
if cpu == 'Intel Xeon MP':
return 'Intel Xeon', 'Xeon MP'
if cpu in ['Intel Xeon', 'Xeon']:
return 'Intel Xeon', 'Xeon (unspecified model)'
if re.match('Intel Xeon (\\d\\.\\d|2M Cache)(Hz)?', cpu):
return 'Intel Xeon', 'Xeon (unspecified model)'
if cpu.startswith('Intel Xeon LV'):
return 'Intel Xeon', 'Xeon LV'
if cpu.startswith('Intel LV Xeon 400'):
return 'Intel Xeon', 'Xeon LV'
if cpu.startswith('Intel Core i'):
return 'Intel Core', cpu[6:]
if cpu.startswith('Intel Core 2 '):
return 'Intel Core', cpu[6:]
if cpu.startswith('Intel Core2 '):
return 'Intel Core', 'Core 2 ' + cpu[12:]
if cpu.startswith('Intel Core '):
return 'Intel Core', cpu[6:]
if cpu.startswith('Intel Pentium D'):
return 'Intel Pentium', cpu[6:]
if re.match('R1\\d000', cpu):
return 'MIPS', cpu
if re.match('MIPS R1\\d000', cpu):
return 'MIPS', cpu[5:11]
i = cpu.find('Pentium 4')
if i >= 0:
return 'Intel Pentium', cpu[i:]
if cpu == 'Intel P4':
return 'Intel Pentium', 'Pentium 4'
if cpu == 'Pentium':
return 'Intel Pentium', 'Pentium'
if cpu in ['Pentium Pro', 'Pentium-Pro']:
return 'Intel Pentium', 'Pentium Pro'
if cpu.startswith('Intel Pentium'):
m = re.match('Intel Pentium ((?:M )?[A-Z]?\\d{3,4}T?)', cpu)
if m:
return 'Intel Pentium', 'Pentium ' + m.group(1)
return 'Intel Pentium', cpu[6:]
if cpu == 'Celeron':
return 'Intel Celeron', 'Celeron'
if cpu.startswith('Intel Celeron'):
return 'Intel Celeron', cpu[6:]
m = re.search('21\\d64[A-Z]*', cpu)
if m:
return 'DEC Alpha', 'Alpha ' + m.group()
if cpu.startswith('POWER'):
return 'IBM POWER', cpu
m = re.search('PowerPC.*', cpu)
if m:
return 'PowerPC', m.group()
if cpu in ['RS64 IV', 'RS64 II']:
return 'PowerPC', cpu
if cpu.startswith('Power'):
return 'IBM POWER', cpu.upper()
if cpu.startswith('IBM Power'):
return 'IBM POWER', cpu.upper()[4:]
if cpu.startswith('P2SC'):
return 'IBM POWER', 'P2SC'
if cpu.startswith('MIPS'):
return 'MIPS', cpu.split()[1]
if re.match('(100 )?R\\d{4}', cpu):
return 'MIPS', cpu
if cpu.startswith('SPARC64'):
return 'Fujitsu SPARC', cpu
if cpu.startswith('MicroSPARC'):
return 'Sun SPARC', cpu
if cpu.startswith('UltraSPARC'):
return 'Sun SPARC', cpu
if cpu.startswith('SuperSPARC'):
return 'Sun SPARC', cpu
if cpu == 'SPARC T3':
return 'Sun SPARC', cpu
if cpu == 'TurboSPARC':
return 'Fujitsu SPARC', 'TurboSPARC'
if cpu in ['512k HyperCACHE', 'HyperSPARC']:
return 'Fujitsu SPARC', 'HyperSPARC'
if cpu == 'ULV Intel Pentium M':
return 'Intel Pentium', 'Pentium M'
if cpu.startswith('AMD FX-'):
return 'AMD FX', cpu[4:]
if cpu.startswith('AMD'):
name = cpu.split()
return 'AMD ' + name[1], ' '.join(name[1:])
if cpu.startswith('Opteron'):
return 'AMD Opteron', cpu
i = cpu.find('Itanium')
if i >= 0:
name = cpu[i:]
name = name.replace('Itanium2', 'Itanium 2')
name = name.replace(' FSB', '')
return 'Intel Itanium', name
if cpu.startswith('PA-'):
cpu = cpu.replace('PA-RISC ', 'PA-')
cpu = cpu.replace('_', '')
return 'HP PA-RISC', cpu
if cpu == 'PA8600':
return 'HP PA-RISC', 'PA-8600'
if 'Xeon' in r.cpu:
return 'Intel Xeon', 'Xeon (unspecified model)'
if r.srec.machine == 'AlphaServer 2100A 5/300':
return 'DEC Alpha', 'Alpha 21164'
return '???', cpu
# ---------------------------------------------------------
# Iterate through CPU95, CPU2000, CPU2006 .csv files
# ---------------------------------------------------------
Result = collections.namedtuple('Result', 'benchType cpu mhz hwDate score srec benches')
DISQUALIFIED_BENCHMARKS = [
# cpu2006
'483.xalancbmk',
'445.gobmk',
'456.hmmer',
'464.h264ref',
'429.mcf',
'462.libquantum'
'434.zeusmp',
'459.GemsFDTD',
'437.leslie3d',
'436.cactusADM',
'470.lbm',
'410.bwaves',
# cpu2017
'657.xz_s',
'648.exchange2_s',
'625.x264_s',
'605.mcf_s',
'602.gcc_s',
'623.xalancbmk_s',
'603.bwaves_s',
'644.nab_s',
'607.cactuBSSN_s',
'638.imagick_s',
'654.roms_s',
'621.wrf_s',
]
def iterCsvRecords(path, className):
with open(path, 'r', encoding="utf8", errors='ignore') as f:
reader = csv.reader(f)
clazz = None
for row in reader:
if clazz is None:
clazz = collections.namedtuple(className, row)
else:
yield clazz(*row)
def iterResults():
benchTable = collections.defaultdict(dict)
for brec in iterCsvRecords('benchmarks.txt', 'BenchmarkRecord'):
benchTable[brec.testID][brec.benchName] = brec
summaryTable = {}
for srec in iterCsvRecords('summaries.txt', 'SummaryRecord'):
summaryTable[srec.testID] = srec
benches = [brec for brec in list(benchTable[srec.testID].values())
if brec.benchName not in DISQUALIFIED_BENCHMARKS]
hwDate = datetime.datetime.strptime(srec.hwAvail, '%b-%Y')
yield Result(benchType=srec.benchType,
cpu=srec.cpu,
mhz=float(srec.mhz),
hwDate=hwDate,
score=geometricAverage([float(brec.base) for brec in benches]),
srec=srec,
benches=benches)
# ---------------------------------------------------------
# Uniquely identify CPUs
# ---------------------------------------------------------
CPUInfo = collections.namedtuple('CPUInfo', 'brand model mhz')
class CPUDatabase(object):
def __init__(self):
self.modelSpeeds = collections.defaultdict(list)
def identify(self, r):
brand, model = identifyCPU(r)
speeds = self.modelSpeeds[brand, model]
for other in speeds:
# if mhz is within 5% of an existing cpu, return that one
if isWithinPercent(r.mhz, other.mhz, 5):
return other
cpu = CPUInfo(brand, model, r.mhz)
speeds.append(cpu)
return cpu
CPUDB = CPUDatabase()
# ---------------------------------------------------------
# Graph rendering
# ---------------------------------------------------------
if 'PIL' in globals():
class HQSurface(object):
def __init__(self, width, height, zooms=2):
self.width, self.height = width, height
self.zooms = zooms
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width * 2 ** zooms, height * 2 ** zooms)
cr = self.cr = cairo.Context(self.surface)
if zooms > 0:
cr.scale(2.0, 2.0)
cr.translate(0.5, 0.5)
for i in range(1, zooms):
cr.scale(2.0, 2.0)
def write_to_png(self, path):
im = PIL.Image.frombuffer('RGBA', (self.surface.get_width(), self.surface.get_height()),
self.surface.get_data(), 'raw', 'BGRA', 0, 1)
for i in range(self.zooms - 1, -1, -1):
im = im.resize((self.width * 2 ** i, self.height * 2 ** i), PIL.Image.BILINEAR)
im.save(path)
# pip3 install pycairo
DEFAULT_FONT_OPTIONS = cairo.FontOptions()
DEFAULT_FONT_OPTIONS.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
def createScaledFont(family, size, slant=cairo.FONT_SLANT_NORMAL, weight=cairo.FONT_WEIGHT_NORMAL):
face = cairo.ToyFontFace(family, slant, weight)
return cairo.ScaledFont(face, cairo.Matrix(xx=size, yy=size), cairo.Matrix(), DEFAULT_FONT_OPTIONS)
def alignText(cr, scaledFont, align, text, x, y):
if isinstance(text, bytes):
text = text.decode('utf-8')
x_bearing, y_bearing, width, height = scaledFont.text_extents(text)[:4]
with saved(cr):
cr.set_font_options(DEFAULT_FONT_OPTIONS)
cr.set_scaled_font(scaledFont)
cr.move_to(x - width * align - x_bearing, y)
cr.show_text(text)
ResultInBrand = collections.namedtuple('ResultInBrand', 'hwDate convertedScore cpu result')
def RenderGraph(mode, resultsByBrand, outPath):
# If 1 pixel travels M months horizontally,
# it should travel M*pixelAspect logScore points vertically,
# and we fix the whole thing inside maxGraphSize.
maxGraphSize = (1920.0, 1080.0)
pixelAspect = 0.06
minLogScore = -6
minDate = datetime.datetime(1995, 1, 1)
# Calculate axis extents and actual graph size.
allRibs = sum(list(resultsByBrand.values()), [])
maxDate = max([r.hwDate for r in allRibs])
months = monthDelta(minDate, maxDate)
maxLogScore = int(round(math.log(max([r.convertedScore for r in allRibs]), 2)))
logScoreRange = maxLogScore - minLogScore
pelsPerMonth = min((maxGraphSize[0] / months),
(maxGraphSize[1] / logScoreRange * pixelAspect))
graphSize = (months * pelsPerMonth, (logScoreRange * pelsPerMonth / pixelAspect))
# Different shapes that are used on the graph.
def circle(cr, x, y):
cr.arc(x, y, 2.5, 0, 2 * math.pi)
def triangle(cr, x, y):
x, y = round(x) + .5, round(y)
cr.move_to(x - 3, y + 3)
cr.line_to(x, y - 3)
cr.line_to(x + 3, y + 3)
cr.close_path()
def square(cr, x, y):
x, y = round(x), round(y)
cr.rectangle(x - 2, y - 2, 5, 5)
# Brands will be rendered in this order, as separate layers.
# That way, we can hide the busiest brands (like Xeon) at the bottom.
brandColors = [
('003471', 'Intel Xeon', square, 0),
('0072bc', 'Intel Core', circle, 1),
('ffa080', 'DEC Alpha', circle, 13),
('007236', 'AMD Opteron', square, 6),
('86dce3', 'Intel Pentium', circle, 2),
('a0d49b', 'AMD Phenom', triangle, 7),
('31d100', 'AMD Athlon', circle, 8),
('377dfc', 'Intel Itanium', triangle, 3),
('fdad4f', 'Fujitsu SPARC', triangle, 11),
('f8e400', 'Sun SPARC', circle, 12),
('c1d72f', 'AMD FX', square, 5),
('d59d55', 'MIPS', square, 14),
('03d3ff', 'Intel Celeron', square, 4),
('f198dd', 'IBM POWER', triangle, 9),
('e040de', 'PowerPC', circle, 10),
('947b30', 'HP PA-RISC', circle, 15),
('947b30', 'AMD EPYC', circle, 16),
]
recognized = set([b[1] for b in brandColors])
# Create surface and context.
w, h = int(graphSize[0] + 40), int(graphSize[1] + 75)
# if 'PIL' in globals():
# surface = HQSurface(w, h)
# cr = surface.cr
# else:
surface = cairo.SVGSurface(outPath + ".svg", w, h)
cr = cairo.Context(surface)
cr.set_line_width(1)
cr.translate(28, 37)
cr.set_source_rgb(1, 1, 1)
cr.paint()
# Title.
mode = mode.lower()
fullType = {'fp': 'Floating-Point', 'int': 'Integer'}[mode]
with saved(cr):
titleFont = createScaledFont('Arial', 20, weight=cairo.FONT_WEIGHT_BOLD)
cr.set_source_rgb(0, 0, 0)
alignText(cr, titleFont, .5, 'Single-Threaded %s Performance' % fullType, (graphSize[0] / 2) - 10, -19)
subTitleFont = createScaledFont('Arial', 11)
cr.set_source_rgb(.6, .6, .6)
alignText(cr, subTitleFont, .5, u'Based on adjusted SPEC%s\xae results' % mode, (graphSize[0] / 2), -5)
# Shaded area.
with saved(cr):
x = round(12 * 9 * pelsPerMonth)
cr.set_source_rgb(.98, .98, .98)
cr.rectangle(x, 0, round(graphSize[0]) - x, round(graphSize[1]))
cr.fill()
# Render grid lines.
with saved(cr):
scoreFont = createScaledFont('Arial', 14)
fractionFont = createScaledFont('Arial', 16)
cr.set_source_rgb(.9, .9, .9)
# Horizontal
for rls in range(maxLogScore - minLogScore + 1):
y = round(graphSize[1] - (rls * pelsPerMonth / pixelAspect))
with saved(cr):
cr.set_source_rgb(.6, .6, .6)
exp = minLogScore + rls
if exp >= 0:
label = str(2 ** exp)
f = scoreFont
else:
label = {
-1: chr(189),
-2: chr(188),
-3: chr(8539),
-4: (chr(0x00B9) + chr(0x2044) + chr(0x2081) + chr(0x2086)).encode('utf-8'),
-5: 'xxx',
}.get(exp, '')
f = fractionFont
alignText(cr, f, 1, label, -6, y + 6)
cr.move_to(0, y + .5)
cr.rel_line_to(graphSize[0], 0)
cr.stroke()
# Vertical
assert minDate.month == 1
for month in range(0, months, 12):
x = round(month * pelsPerMonth)
cr.move_to(x + .5, 0)
cr.rel_line_to(0, graphSize[1])
cr.stroke()
cr.move_to(round(months * pelsPerMonth) + .5, 0)
cr.rel_line_to(0, graphSize[1])
cr.stroke()
yearFont = createScaledFont('Arial', 13)
for month in range(6, months, 12):
x = month * pelsPerMonth
with saved(cr):
cr.set_source_rgb(.6, .6, .6)
cr.translate(x, graphSize[1])
cr.rotate((-math.pi / 4))
alignText(cr, yearFont, 1, str(minDate.year + (month / 12)), -4, 12)
# Render each brand as another layer.
totalPoints = 0
with saved(cr):
for color, brand, shape, listOrder in [('808080', None, circle, -1)] + sorted(brandColors):
if brand:
rib = resultsByBrand[brand]
else:
rib = sum([rib for b, rib in list(resultsByBrand.items()) if b not in recognized], [])
cr.set_source_rgb(*[int(color[i:i + 2], 16) / 255.0 for i in range(0, 6, 2)])
for r in rib:
logScore = math.log(r.convertedScore, 2)
x = (monthDelta(minDate, r.hwDate) - .5) * pelsPerMonth
y = ((logScore - minLogScore) * pelsPerMonth / pixelAspect)
if x >= 0 and y >= 0:
totalPoints += 1
shape(cr, x, graphSize[1] - y)
cr.fill()
print('%d points plotted for SPEC%s' % (totalPoints, mode))
# Render legend.
with saved(cr):
legendFont = createScaledFont('Arial', 11)
spacing = 11
w, h = 90, spacing * len(brandColors) + 4
cr.translate(int(graphSize[0]) - w - 23, int(graphSize[1]) - h - 23)
cr.set_source_rgb(1, 1, .98)
cr.rectangle(0, 0, w, h)
cr.fill()
cr.set_source_rgb(.7, .7, .7)
cr.rectangle(.5, .5, w, h)
cr.stroke()
cr.translate(7, 9)
for color, brand, shape, listOrder in brandColors:
# Icon
cr.set_source_rgb(*[int(color[i:i + 2], 16) / 255.0 for i in range(0, 6, 2)])
shape(cr, 0, listOrder * spacing - 1)
cr.fill()
# Text
cr.set_source_rgb(0, 0, 0)
alignText(cr, legendFont, 0, brand, 6, listOrder * spacing + 3)
surface.write_to_png(outPath + ".png")
# ---------------------------------------------------------
# Main
# ---------------------------------------------------------
ALL_RESULTS = list(iterResults())
for r in ALL_RESULTS:
CPUDB.identify(r)
# Dump table of identified CPU names.
# Good for tweaking identifyCPU.
with redirected_to_file('identified_cpus.txt'):
# Number of CPUs in each brand:
brand = None
for k, speeds in sorted(CPUDB.modelSpeeds.items()) + [((None, ''), [])]:
if brand != k[0]:
if brand is not None:
print('%s x %d' % (brand, count))
brand = k[0]
count = 0
count += 1
print()
# Individual models:
table = dict([(r.cpu, r) for r in ALL_RESULTS])
for dummy, r in sorted(table.items()):
cpu = CPUDB.identify(r)
identifier = '%s|%s (%d Mhz)' % (cpu.brand, cpu.model, r.mhz)
print('%-60s "%s" %s#%s' % (identifier, r.cpu, r.benchType, r.srec.testID))
print('%-60s "%s" %s#%s' % (identifier, r.cpu, r.benchType, r.srec.testID))
# Scan INT benchmarks, then FP.
for MODE in ['INT', 'FP']:
benchTypes = [t % MODE for t in ['C%s95', 'C%s2000', 'C%s2006', 'C%s2017']]
# resultsByCPU: Maps CPUInfo to a list of results using that cpu.
resultsByCPU = collections.defaultdict(list)
# Iterate through all results.
for r in ALL_RESULTS:
if r.benchType in benchTypes:
cpu = CPUDB.identify(r)
resultsByCPU[cpu].append(r)
# Find conversion ratios by taking the geometric average of all
# available conversion ratios.
ratio2000 = []
ratio2006 = []
ratio2017 = []
for cpu, results in list(resultsByCPU.items()):
sliceByType = [[r.score for r in results if r.benchType == b] for b in benchTypes]
if sliceByType[0] and sliceByType[1]:
# We have a 2000/95 conversion ratio for this CPU.
ratio2000.append((geometricAverage(sliceByType[1]) / geometricAverage(sliceByType[0])))
if sliceByType[1] and sliceByType[2]:
# We have a 2006/2000 conversion ratio for this CPU.
ratio2006.append((geometricAverage(sliceByType[2]) / geometricAverage(sliceByType[1])))
if sliceByType[2] and sliceByType[3]:
# We have a 2017/2006 conversion ratio for this CPU.
ratio2017.append((geometricAverage(sliceByType[3]) / geometricAverage(sliceByType[2])))
ratio2000 = geometricAverage(ratio2000)
ratio2006 = geometricAverage(ratio2006)
ratio2017 = geometricAverage(ratio2017)
conversionRatios = [ratio2000 * ratio2006 * ratio2017, ratio2006 * ratio2017, ratio2017, 1]
# Group results by brand, convert scores and sort.
resultsByBrand = collections.defaultdict(list)
for cpu, results in list(resultsByCPU.items()):
for r in results:
convertedScore = r.score * conversionRatios[benchTypes.index(r.benchType)]
resultsByBrand[cpu.brand].append(ResultInBrand(r.hwDate, convertedScore, cpu, r))
for rib in list(resultsByBrand.values()):
rib.sort()
# Dump results file.
with redirected_to_file('%s_report.txt' % MODE.lower()):
print('%s = %f x %s' % (benchTypes[1], ratio2000, benchTypes[0]))
print('%s = %f x %s' % (benchTypes[2], ratio2006, benchTypes[1]))
print('%s = %f x %s' % (benchTypes[3], ratio2017, benchTypes[2]))
print()
for brand, rib in sorted(resultsByBrand.items()):
print()
print()
print(brand)
print('=' * len(brand))
for hwDate, convertedScore, cpu, result in rib:
print(' %s: %f by "%s" %d MHz (%s=%.1f, %s) %s' % (
hwDate.strftime('%Y-%b'),
convertedScore,
cpu.model,
cpu.mhz,
result.benchType,
result.score,
result.srec.testID,
', '.join([brec.base for brec in result.benches])))
# Render the graph.
if 'cairo' in globals():
RenderGraph(MODE, resultsByBrand, '%s_graph' % MODE.lower())