From: Gary S. <st...@nm...> - 2002-06-21 15:35:29
|
Hi all, This might be a bit off-topic--perhaps hardware related(?)--but does anyone know exactly what happens when you pick value of N such that your computer can't handle a given "rate(N)" visualpython statement? Do frames get dropped? Or is it dependent on one's graphics card, or screen refresh rates, or openGL implementation? Using the program below, my _actual_ framerate increases as a stair-stepped function of the _specified_ framerate. What I find odd is that the _actual_ framerate does keep on increasing. That is, rate(50) doesn't give me a 50Hz frame rate, but (according to my loop anyway) using rate(100) gives me a better than 50Hz frame rate. I would think that the actual framerate should increase linearly to the point where one's computer is maxed out, and then plateau indefinitely. Apparently that's naive. Any ideas? I've tested this on both a couple machines (though both are portables with, of course, LCD monitors). Thanks in advance for any guesses (or better yet, answers) ... Gary strang-@at@-nmr.mgh.harvard.edu --- cut here --- from visual import * import time, sys, whrandom scene.title = "Speed test" # Create 2 frames fworld = frame(pos=(0,0,0)) ftarget = frame(frame=fworld,pos=(0,0,0)) ftarget.pos = (0,0,0) fworld.pos = (0,0,10) # Draw some main objects body = cylinder(frame=ftarget, pos=(0,0,0), axis=(0,0,0.35), radius=1, color=(0,0,1),visible=1) pin = cylinder(frame=ftarget, pos=(0,1,0), axis=(0,1,0), radius=1, color=(1,1,1),visible=1) pinball = sphere(frame=ftarget, pos=(0,-1,0), radius=1, color=(1,1,0),visible=1) topbox = box(frame=ftarget, pos=(0,0.34,0.20), axis=(0,1,0), length=0.2,width=0.1,height=0.1, color=(1,0,0),visible=1) horizon = cylinder(frame=ftarget, pos=(-5,2,0), axis=(10,0,0), radius=1, color=(0,1,0),visible=1) xINC = 0 yINC = 0.001 zINC = 0.003 rollINC = 0 pitchINC = 0 yawINC = 0 scene.autoscale = 0 NUM_DOTS = 500 RADIUS = 120 rad = 0.4 # now draw background objects for i in range(0, NUM_DOTS): x = whrandom.random() - 0.5 y = whrandom.random() - 0.5 z = whrandom.random() - 0.5 length = math.sqrt(x*x + y*y + z*z) x = x / length * RADIUS y = y / length * RADIUS + 1.8 z = z / length * RADIUS sphere(pos=(x,y,z),radius=rad) frameratelist = [] for framerate in range(10,250,1): framecount = 0 starttime = time.clock() while framecount<5*framerate: # integrate over, theoretically, 5sec rate(framerate) framecount += 1 fworld.pos.x -= xINC fworld.pos.y -= yINC fworld.pos.z = framecount*zINC # Rotate "CAMERA" (actually, move whole _world_ around camera) fworld.rotate(angle=pitchINC, axis=(1,0,0), origin=scene.mouse.camera) fworld.rotate(angle=yawINC, axis=(0,1,0), origin=scene.mouse.camera) fworld.rotate(angle=rollINC, axis=(0,0,1), origin=scene.mouse.camera) endtime = time.clock() print "Rate(%i): %i frames in %2.2f sec = %2.2f frames/sec" % (framerate, framecount, (endtime-starttime), framecount/(endtime-starttime)) frameratelist.append((framerate, framecount, (endtime-starttime), framecount/(endtime-starttime))) |