xrange makes no difference. And, yes, I've run the Welcome program dozens of times and the results are very consistent. There is little randomness in time.time().
My Linux server is a dedicated machine at the datacentre. I have it all to myself. Not much else is running on it. Apache2, web2py. On Friday, 14 March 2014 10:53:38 UTC-4, Jonathan Lundell wrote: > > On 14 Mar 2014, at 7:39 AM, horridohobbyist > <horrido...@gmail.com<javascript:>> > wrote: > > Okay, version 2.6.5 is verified. No difference in the Python version. > > > > So how to explain the performance difference? > > It's getting to be interesting. > > To make the result more robust, I'd try it with a much bigger range, maybe > 100x, to be sure that the per-loop time is dominating the report. And just > for the heck of it I'd replace range with xrange to see if it makes any > difference at all. > > Something else to keep in mind, especially if you're running this on a > shared VM, is that time.time() is giving you clock time, and that can lead > to very random results in a shared-hardware environment. Or even in a > non-shared one, if there's any other system activity going on. The only way > around that is to repeat the experiment a lot (which you're doing, sounds > like). > > > > > > > On Friday, 14 March 2014 09:36:29 UTC-4, Jonathan Lundell wrote: > > On 14 Mar 2014, at 6:28 AM, horridohobbyist <horrido...@gmail.com> > wrote: > >> I conducted a simple experiment. I took the "Welcome" app, surely the > simplest you can have (no databases, no concurrency, etc.), and added the > following to the index page: > >> > >> def test(): > >> start = time.time() > >> x = 0.0 > >> for i in range(1,5000): > >> x += (float(i+10)*(i+25)+175.0)/3.14 > >> debug("elapsed time: "+str(time.time()-start)) > >> return > >> > >> I get an elapsed time of 0.103 seconds. > >> > >> The same exact code in a command line program... > >> > >> if __name__ == '__main__': > >> test() > >> > >> gives an elapsed time of 0.003 seconds. That's 35 times faster! It's > not the 2 orders of magnitude I'm seeing in the pyShipping code, but my > point is proven. There is something hinky about web2py that makes Python > code execute much more slowly. Is web2py using a different Python version? > As far as I can tell, I only have Python 2.6.5 installed on my Linux > server. > >> > > > > Easy enough to find out: print sys.version. > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.