From: Bruce S. <Bru...@nc...> - 2010-05-02 01:25:13
|
Having seen the whole program, I realized that there's a missing "num += 1" in the while loop in add_points, which meant that you were creating an infinite number of spheres. After that correction, however, on my machine rotating the view was sluggish until I changed from sphere to points, in which case the program runs very fast and rotation is smooth: def simulate_hyper(): from visual import rate, points #sphere positions = points() def add_points(): num = 0 while num < 1000: positions.append(pos=get_point()) ## sphere(pos=get_point(), radius = 2**55) num += 1 On 5/1/2010 8:40 PM, Thomas Spura wrote: > I didn't want to publish all my whacky code on a mailinglist, that's > because there was something missing ;) > > The huge radius is because in get_point it creates 3 random numbers in > the range of -2**63-1 to 2**63. With a smaller radius, you don't see > anything. > > Attached is my code (quite experimental, but working). > "python -m cProfile own_random.py" is working > "python -m cProfile 3d_test.py" only shows the window, but no profile :( > > > I'll try the points object out later. It would be nice to get a proper > profile of the run, so we find out the bottleneck, maybe it's in my > loop, maybe vpython could be speeded up anyhow :) > > Thanks for the fast reply. > > Thomas > > Am Samstag, den 01.05.2010, 20:22 -0400 schrieb Bruce Sherwood: > >> I don't know anything about profiling and hope someone else will >> comment, though I can say that VPython is multithreaded (the graphical >> rendering thread runs periodically, interrupting the Python >> computational thread). I don't know whether that matters. >> >> The program fragment you provide is incomplete: what is "get_point()"? >> Why the gigantic sphere radius of 2**55 = 3.6e16? >> >> I would guess that the points object would run faster than a bunch of >> sphere objects. >> >> Bruce Sherwood >> >> On 5/1/2010 8:02 PM, Thomas Spura wrote: >> >>> Hi list, >>> >>> I try to a hyperplane in random generated points, which is atm really >>> slow (could be, that it can be done faster, when implemented >>> differently...) >>> >>> from visual import rate, sphere >>> >>> def add_points(): >>> num = 0 >>> while num< 1000: >>> sphere(pos=get_point(), radius = 2**55) >>> >>> points = 0 >>> while 1: >>> rate(100) >>> if points< 10000: >>> add_points() >>> points += 1000 >>> print points >>> >>> Therefore I tried to profile it with cProfile and ran it as: >>> "python -m cProfile my_script.py" >>> >>> This worked for any other 'usual' script, but not with the script from >>> above. >>> >>> Am I missing something? Is it not possible with vpython by intention? >>> >>> Thomas >>> >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> Visualpython-users mailing list >>> Vis...@li... >>> https://lists.sourceforge.net/lists/listinfo/visualpython-users >>> >>> > |