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
| %matplotlib inline from matplotlib import pyplot as plt import time lst1=[] lst2=[] y1=[] y2=[]
for i in [60,100,150,200,280,340,400,500,600,700]: start = time.clock() coin_charge((1,2,5),i) lst1.append(time.clock()-start)
for i in [60,100,150,200,280,340,400,500,600,700]: start = time.clock() coin_charge_cache((1,2,5),i) lst2.append(time.clock()-start)
y1.append(lst1[0]) y2.append(lst2[0]) x=[60,100,150,200,280,340,400,500,600,700] x1=[0]
for i in range(1,len(lst1)): y1.append(lst1[i]/lst1[0]) y2.append(lst2[i]/lst2[0]) x1.append(x[i]/x[0])
print(x1) print(y1) print(y2)
plt.plot(x1,y1,label="coin_charge") plt.plot(x1,y2,label="coin_charge_cache") plt.title("Example") plt.xlabel("N-Growth") plt.ylabel("Time-Growth") plt.legend() plt.show()
from graphviz import Digraph dot = Digraph() dot.format = 'svg' dot.graph_attr['bgcolor']='transparent'
dot.node_attr={'color':'gray80','fontcolor':'black','style':'rounded','shape':'record'} dot.edge_attr={'color':'gray60','fontcolor':'gra60','fontcolor':'brown1'} dot.attr('node') dot.node('A','{Sum_find([1,2],3)|2}') dot.node('B','{Sum_find([2],3)|0}') dot.node('C','{Sum_find([1,2],2)|2}') dot.node('B1','{Sum_find([],3)|0}') dot.node('B2','{Sum_find([2],1)|0}') dot.node('B21','{Sum_find([],1)|0}') dot.node('C1','{Sum_find([2],2)|1}') dot.node('C2','{Sum_find([1,2],1)|1}') dot.node('C11','{Sum_find([0],2)|0}') dot.node('C12','{Sum_find([2],0)|1}') dot.node('C21','{Sum_find([2],1)|0}') dot.node('C22','{Sum_find([1,2],0)|1}') dot.node('C211','{Sum_find([],1)|0}') dot.edge('A','B') dot.edge('A','C') dot.edge('B','B1') dot.edge('B','B2') dot.edge('C','C1') dot.edge('C','C2') dot.edge('B2','B21') dot.edge('C1','C11') dot.edge('C1','C12') dot.edge('C2','C21') dot.edge('C2','C22') dot.edge('C21','C211') dot.render('D:index11') dot
|