MCPcopy Create free account
hub / github.com/casadi/casadi / complexity

Method complexity

test/python/complexity.py:119–151  ·  view source on GitHub ↗
(self,setupfun,fun, order, depth = 0)

Source from the content-addressed store, hash-verified

117
118
119 def complexity(self,setupfun,fun, order, depth = 0):
120
121 N = 1
122
123 Ns = []
124 ts = []
125
126 dt = 0
127 while dt<self.maxt:
128 sys.stdout.write("\r%d..." % N)
129 sys.stdout.flush()
130 p = setupfun(self,N) # Setup
131 for i in range(10):
132 t = time()
133 fun(self,N,p) # Run the function
134 dt = time()-t
135 Ns.append(N)
136 ts.append(dt)
137 N=int(N*1.5)
138 N+=1
139 if self.check: break
140 print("")
141
142 Ns = array(Ns)
143 ts = array(ts)
144 valid = ts > self.mint
145 if not(self.check):
146 orders = self.checkOrders(Ns[valid],ts[valid])
147 if not(self.check) and (len(orders)!=1 or orders[0]!=order):
148 if (depth<3):
149 return self.complexity(setupfun,fun, order, depth+1 )
150 else:
151 self.assertTrue(False,"We expected order %d, but found %s" % (order,str(orders)))
152
153
154 def test_DMadd(self):

Callers 7

test_DMaddMethod · 0.95
test_SX_funaddMethod · 0.95
test_SX_funprodvecMethod · 0.95
test_SX_funprodsparseMethod · 0.95
test_MX_funprodvecMethod · 0.95
test_MX_funprodsparseMethod · 0.95
test_DMdotMethod · 0.95

Calls 7

checkOrdersMethod · 0.95
rangeFunction · 0.85
strFunction · 0.85
flushMethod · 0.80
printFunction · 0.50
writeMethod · 0.45
appendMethod · 0.45

Tested by 7

test_DMaddMethod · 0.76
test_SX_funaddMethod · 0.76
test_SX_funprodvecMethod · 0.76
test_SX_funprodsparseMethod · 0.76
test_MX_funprodvecMethod · 0.76
test_MX_funprodsparseMethod · 0.76
test_DMdotMethod · 0.76