2 # Generated python file of Graph GraphCpuUsed
6 GraphCpuUsed = Graph( 'GraphCpuUsed' )
7 GraphCpuUsed.SetName( 'GraphCpuUsed' )
8 GraphCpuUsed.SetAuthor( '' )
9 GraphCpuUsed.SetComment( '' )
10 GraphCpuUsed.Coords( 0 , 0 )
12 # Creation of Factory Nodes
14 sigma = GraphCpuUsed.FNode( 'FactorialComponent' , 'FactorialComponent' , 'sigma' )
15 sigma.SetName( 'sigma' )
16 sigma.SetAuthor( 'JR' )
17 sigma.SetContainer( 'localhost/FactoryServerPy' )
18 sigma.SetComment( 'sigma from FactorialComponent' )
19 sigma.Coords( 214 , 172 )
21 Sigma = GraphCpuUsed.FNode( 'AddComponent' , 'AddComponent' , 'Sigma' )
22 Sigma.SetName( 'Sigma' )
24 Sigma.SetContainer( 'localhost/FactoryServer' )
25 Sigma.SetComment( 'Sigma from AddComponent' )
26 Sigma.Coords( 418 , 21 )
28 # Creation of InLine Nodes
30 PyAdd.append( 'from time import * ' )
31 PyAdd.append( 'def Add(a,b) : ' )
32 PyAdd.append( ' print "Add will wait 5 seconds" ' )
33 PyAdd.append( ' d = dir() ' )
34 PyAdd.append( ' print "Add",d ' )
35 PyAdd.append( ' d = dir(sleep) ' )
36 PyAdd.append( ' print "Add",d ' )
37 PyAdd.append( ' sleep(5) ' )
38 PyAdd.append( ' print "Add waited" ' )
39 PyAdd.append( ' n = 0 ' )
40 PyAdd.append( ' while n < 10000 : ' )
41 PyAdd.append( ' i = 0 ' )
42 PyAdd.append( ' s = 0 ' )
43 PyAdd.append( ' while i <= b : ' )
44 PyAdd.append( ' s = s + i ' )
45 PyAdd.append( ' i = i + 1 ' )
46 PyAdd.append( ' n = n + 1 ' )
47 PyAdd.append( ' return s ' )
49 Add = GraphCpuUsed.INode( 'Add' , PyAdd )
50 Add.InPort( 'a' , 'long' )
51 Add.InPort( 'b' , 'long' )
52 Add.OutPort( 'f' , 'long' )
55 Add.SetComment( 'Python function' )
59 PySub.append( 'def Sub(a,b) : ' )
60 PySub.append( ' return a-b ' )
62 Sub = GraphCpuUsed.INode( 'Sub' , PySub )
63 Sub.InPort( 'a' , 'long' )
64 Sub.InPort( 'b' , 'long' )
65 Sub.OutPort( 'f' , 'long' )
68 Sub.SetComment( 'Python function' )
72 PyCompare.append( 'def Compare( Add , sigma , Sigma ) : ' )
73 PyCompare.append( ' Result = "Good" ' )
74 PyCompare.append( ' if Add != sigma : ' )
75 PyCompare.append( ' Result = "Bad" ' )
76 PyCompare.append( ' if Add != Sigma : ' )
77 PyCompare.append( ' Result = "Bad" ' )
78 PyCompare.append( ' return Result ' )
79 PyCompare.append( '' )
80 Compare = GraphCpuUsed.INode( 'Compare' , PyCompare )
81 Compare.InPort( 'Add' , 'long' )
82 Compare.InPort( 'Sigma' , 'long' )
83 Compare.InPort( 'sigma' , 'long' )
84 Compare.OutPort( 'Result' , 'string' )
85 Compare.SetName( 'Compare' )
86 Compare.SetAuthor( '' )
87 Compare.SetComment( 'Compute Node' )
88 Compare.Coords( 419 , 184 )
91 Addf = Add.Port( 'f' )
92 CompareAdd = GraphCpuUsed.Link( Addf , Compare.Port( 'Add' ) )
93 CompareAdd.AddCoord( 1 , 411 , 265 )
94 CompareAdd.AddCoord( 2 , 411 , 169 )
95 CompareAdd.AddCoord( 3 , 617 , 169 )
96 CompareAdd.AddCoord( 4 , 618 , 8 )
97 CompareAdd.AddCoord( 5 , 401 , 8 )
98 CompareAdd.AddCoord( 6 , 400 , 80 )
100 Subf = Sub.Port( 'f' )
101 Addb = GraphCpuUsed.Link( Subf , Add.Port( 'b' ) )
102 Addb.AddCoord( 1 , 189 , 108 )
103 Addb.AddCoord( 2 , 191 , 220 )
105 sigman = GraphCpuUsed.Link( Subf , sigma.Port( 'n' ) )
106 sigman.AddCoord( 1 , 206 , 254 )
107 sigman.AddCoord( 2 , 206 , 220 )
109 Sigman = GraphCpuUsed.Link( Subf , Sigma.Port( 'n' ) )
110 Sigman.AddCoord( 1 , 389 , 101 )
111 Sigman.AddCoord( 2 , 390 , 160 )
112 Sigman.AddCoord( 3 , 190 , 161 )
113 Sigman.AddCoord( 4 , 190 , 220 )
115 sigmaf = sigma.Port( 'f' )
116 Comparesigma = GraphCpuUsed.Link( sigmaf , Compare.Port( 'sigma' ) )
117 Comparesigma.AddCoord( 1 , 386 , 323 )
118 Comparesigma.AddCoord( 2 , 385 , 253 )
120 Sigmaf = Sigma.Port( 'f' )
121 CompareSigma = GraphCpuUsed.Link( Sigmaf , Compare.Port( 'Sigma' ) )
122 CompareSigma.AddCoord( 1 , 400 , 295 )
123 CompareSigma.AddCoord( 2 , 400 , 153 )
124 CompareSigma.AddCoord( 3 , 595 , 153 )
125 CompareSigma.AddCoord( 4 , 595 , 102 )
127 # Creation of Input datas
128 Adda = Add.Input( 'a' , 1)
129 Suba = Sub.Input( 'a' , 1000)
130 Subb = Sub.Input( 'b' , 1)
132 # Creation of Output variables
133 CompareResult = Compare.Port( 'Result' )
137 GraphCpuUsed.PrintPorts()
138 print "sigma",sigma.CpuUsed(),"seconds"
139 print "Sigma",Sigma.CpuUsed(),"seconds"
140 print "Add",Add.CpuUsed(),"seconds"
141 print "Sub",Sub.CpuUsed(),"seconds"
142 print "Compare",Compare.CpuUsed(),"seconds"