I see 13 sec to an agonizing 55 sec execution time for the script below when max_v in def problem is set to 700. The first time it often runs in 13 sec but the next time it takes 55 sec. How can this be!!! What do I need to do in order to consistently get the faster time? I did some tests:
max_v time
100 2.6 sec
200 3.6 sec to 7.6 sec
400 8 sec to 21 sec
700 13 sec to 55 sec
The display is disabled for all these tests. Is there some kind of garbage collection going on for the larger sizes of the 2D matrix variable? 100k entries seems mostly reproducible but 200k to 700k can increase by 400% in execution time.
Please try this simple script yourself and let me know your results. Set max_v to a value and try multiple executions. Are the times consistent? Is a graph of time vs max_v reasonably linear?
import rhinoscriptsyntax as rs
from Rhino.Geometry import Point3d
from time import time
P3d = Point3d
def problem(srf):
time1 = time()
max_u = 1070.; max_v = 700.
a = []
for i in range(int(max_u)):
b = []
for j in range(int(max_v)): b.append(rs.EvaluateSurface(srf, i, j))
a.append(b)
print 'Time to fill matrix = ', time() - time1
return()
def makeBase():
pts = [P3d(0,0,942),P3d(0,88,953), P3d(0,175,964), P3d(0,263,973), P3d(0,350,983), P3d(0,438,991), P3d(0,525,986), P3d(0,613,991), P3d(0,700,1000),
P3d(220,0,951), P3d(220,88,969), P3d(220,175,976), P3d(220,263,988), P3d(220,350,995), P3d(220,438,1000),P3d(220,525,1000),P3d(220,613,1002),P3d(220,700,999),
P3d(267,0,959), P3d(267,88,969), P3d(267,175,977), P3d(267,263,982), P3d(267,350,994), P3d(267,438,998), P3d(267,525,1000),P3d(267,613,1002),P3d(267,700,987),
P3d(535,0,934), P3d(535,88,945), P3d(535,175,955), P3d(535,263,963), P3d(535,350,971), P3d(535,438,962), P3d(535,525,967), P3d(535,613,975), P3d(535,700,961),
P3d(802,0,890), P3d(802,88,906), P3d(802,175,916), P3d(802,263,922), P3d(802,350,912), P3d(802,438,913), P3d(802,525,912), P3d(802,613,929), P3d(802,700,902),
P3d(1070,0,857),P3d(1070,88,876),P3d(1070,175,874),P3d(1070,263,865),P3d(1070,350,835),P3d(1070,438,873),P3d(1070,525,835),P3d(1070,613,853),P3d(1070,700,855)]
srf = rs.AddSrfPtGrid([6,9], pts, [3,3], [False, False])
return(srf)
# Clear document
rs.EnableRedraw(False)
rs.DeleteObjects(rs.AllObjects())
srf = makeBase()
problem(srf)
rs.EnableRedraw(True)