#!/usr/bin/env python3
from pylab import * # uses Matplotlib
import matplotlib.dates as mdates
import datetime
# Date First Last Sum
# Data is from HTML source at http://top500.org/statistics/perfdevel/
li = """1993-05-01,59.7,0.42,1128.57
1993-10-01,124,0.47,1493.35
1994-05-01,143.4,0.84,2317.01
1994-10-01,170,1.16,2732.24
1995-05-01,170,1.96,3927
1995-10-01,170,2.49,4784.34
1996-05-01,220.4,3.31,5892.24
1996-10-01,368.2,4.62,7981.24
1997-05-01,1068,7.67,12844.19
1997-10-01,1338,9.51,16898.12
1998-05-01,1338,13.39,22625.14
1998-10-01,1338,17.12,29367.6
1999-05-01,2121,24.7,39062.57
1999-10-01,2379,33.09,50938.56
2000-05-01,2379,43.82,64230.11
2000-10-01,4938,55.3,88082.45
2001-05-01,7226,67.78,108276.78
2001-10-01,7226,94.3,134977.51
2002-05-01,35860,134.3,222263.77
2002-10-01,35860,195.8,291814.16
2003-05-01,35860,241.4,370049.26
2003-10-01,35860,378.6,526740.41
2004-05-01,35860,606.9,812313.21
2004-10-01,70720,840.02,1128834.52
2005-05-01,136800,1166,1694886.64
2005-10-01,280600,1645.7,2299341.68
2006-05-01,280600,2026,2789465.47
2006-10-01,280600,2736.9,3527867.61
2007-05-01,280600,4031,4950600.48
2007-10-01,478200,5937.33,6977593.51
2008-05-01,1026000,8996.78,12152691.08
2008-10-01,1105000,12593.5,17373520.05
2009-05-01,1105000,17110,22640789.57
2009-10-01,1759000,20070,28006450.09
2010-05-01,1759000,24670,32434684.56
2010-10-01,2566000,31124.36,43786881.73
2011-05-01,8162000,40187.29,58930025.84
2011-10-01,10510000,50941.4,74069633.68
2012-05-01,16324751,60824.4,123417786.71
2012-10-01,17590000,76411,162139386.75
2013-05-01,33862700,96619,223654338.13
2013-10-01,33862700,117831.30,250080467.17
2014-05-01,33862700,133700,273763781.09
2014-10-01,33862700,153381,308850512.09
2015-05-01,33862700.00,164559,359296049.36
2015-10-01,33862700.00,206304,417807043.60
2016-05-01,93014593.88,286100,567353038.81
2016-10-01,93014593.88,349333,672112377.49
2017-05-01,93014593.88,432200,748700301.81
2017-10-01,93014593.88,548672,845120504.67
2018-05-01,122300000.00,715551,1210914864.08
2018-10-01,143500000.00,874800,1414955581.78
2019-05-01,148600000,1021000,1559575379.78
2019-10-01,148600000,1142000,1646887142.78
2020-05-01,415530000,1228000,2206134393.77
2020-10-01,442010000,1316840,2428761851.77
2021-05-01,442010000,1511000,2786058799.77
2021-10-01,442010000,1649110,3036861783.77
"""
x, y1, y2, y3 = [], [], [], []
for line in li.splitlines():
e = line.split(',')
y, m, d = [int(w) for w in e[0].split('-')]
f, l, s = [float(q) for q in e[1:]]
x.append(datetime.date(y, m, d))
y1.append(f)
y2.append(l)
y3.append(s)
figure(figsize=(18,10))
semilogy(x, y1, label = "#1", lw = 2, color = "red", marker = "d")
semilogy(x, y2, label = "#500", lw = 2, color = "orange", marker = "p")
semilogy(x, y3, label = "Sum", lw = 2, color = "blue", marker = "s")
legend(loc = "upper left")
xlabel('Year')
ylabel('Performance (GFlop/s)')
grid('on')
xticks([datetime.date(y,1,1) for y in range(1990, 2050)])
yticks([10**x for x in range(-1, 20)])
axis((datetime.date(1993,1,1),datetime.date(2023,1,1), .1, 1e11))
ax = gca()
ax.xaxis.set_major_formatter(mdates.ConciseDateFormatter(ax.xaxis.get_major_locator()))
savefig("top500_supercomputers_performance_development.svg")
show()