From: James R. <u32...@an...> - 2004-01-13 05:56:10
|
Hi, I'm using vpython in computational simulation. A little concerned about the efficiency, I ran the following tests: from visual import * import profile import datetime def dostuff(n): for i in range(n): for i in range(n): pass timea = datetime.datetime.today() profile.run("dostuff(1500)") timeb = datetime.datetime.today() t = timeb - timea print "Actual running time: %i.%i seconds" % (t.seconds, t.microseconds) ball = sphere(pos=(0,0,0), radius=1) timea = datetime.datetime.today() profile.run("dostuff(1500)") timeb = datetime.datetime.today() t = timeb - timea print "Actual running time: %i.%i seconds" % (t.seconds, t.microseconds) And I got this output: Visual-2003-10-05 3 function calls in 1.250 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.240 1.240 <string>:1(?) 1 0.010 0.010 1.250 1.250 profile:0(dostuff(1500)) 0 0.000 0.000 profile:0(profiler) 1 1.240 1.240 1.240 1.240 visualanalysis.py:5(dostuff) Actual running time: 1.338290 seconds Xlib: extension "XFree86-DRI" missing on display ":0.0". 3 function calls in 2.040 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 2.040 2.040 <string>:1(?) 1 0.000 0.000 2.040 2.040 profile:0(dostuff(1500)) 0 0.000 0.000 profile:0(profiler) 1 2.040 2.040 2.040 2.040 visualanalysis.py:5(dostuff) Actual running time: 10.847798 seconds This in my view is pretty poor efficiency, considering that visual python is doing nothing but displaying a static ball on the second call to dostuff(). Is there anyway to tell visual python to lay off and do nothing for a while? So... in the context of my work, when I call the functions that do all the hard work, i would tell visual python to do nothing, and then when the functions return, i'd tell visual python to start doing stuff again. BTW, what is it doing that slows everything down so much? -- James Roper Summer Research Scholar Department of Computer Science Fourth Year Software Engineer Department of Computer Science Australian National University "A deceptively simple architectural challenge faced by many multi-tasking applications is gracefully doing nothing." Glyph Lefkowitz |