Well well, it was some time that someone didn't start a "web2py is slow(er) 
thread". 

<start mode="resuming old dir of all kinds of tests to verify that the user 
is wrong">

let's start clearing some field....

ubuntu 12.10 64 bit, python 2.7.3. Original script:

# -*- coding: utf-8 -*-
import time
def test():
    start = time.time()
    x = 0.0
    for i in range(1,50000):
        x += (float(i+10)*(i+25)+175.0)/3.14
    res = str(time.time()-start)
    return "elapsed time: "+ res + '\n'

if __name__ == '__main__':
    print test()

vs the attached app (one controller only, same function, without the 
"__main__" logic). 
#commented lines is my brain working

>>> ./web2py.py -a password ...
>>> curl http://127.0.0.1:8000/pyperf/default/test
0.27 min, 0.32 max, ~0.29 mean
#kill web2py, we got a baseline
#let's execute the original script
>>> python originalscript.py
0.17 min, 0.25 max, ~0.20 mean
#oh gods. User is right... Something is slower. Ok, let's test web2py 
"real" overhead using shell mode
>>> ./web2py.py -M -S pyperf/default/test
0.17 min, 0.25 max, ~0.20 mean
#roger... something in the "web world" is making things slower. Maybe 
rocket or the infamous GIL ?!?!
#let's go with uwsgi!!!
>>> uwsgi -i web2py.ini
>>> curl http://127.0.0.1:8000/pyperf/default/test
0.25 min, 0.30 max, ~0.27 mean
# just kidding! even uwsgi is slower than originalscript.py. so it's web2py.
# wait a sec. I know a tonload of webframeworks, but I'll pick one of the 
smallest to introduce as less overhead as I can
# let's go with web.py (app_perf.py) 
>>> curl http://127.0.0.1:8000/pyperf
0.27 min, 0.31 max, ~0.29 mean
#gotta be kidding me. No taste whatsoever in choosing frameworks. All my 
choiches are taking 2x hit.
#let's go with the superduper flask (often recognized as one of the best 
performance-wise, without going full-blown esotherical)
# attached app_flask_perf.py
>>> curl http://127.0.0.1:8000/pyperf
0.27 min, 0.31 max, ~0.29 mean
# OMG! not frameworks' fault. this is wsgi fault.


So.... seems that web2py shell and python script behaves exactly the same 
(if web2py was introducing complexity it should show right there).
The same environment executed by rocket or uwsgi gets some gap (roughly 2x 
time).
uwsgi behaves a little better, but not that much (surely in concurrency but 
that's another deal).
Every wsgi implementation takes the hit, micro or macro framework.

Soooo.... maybe the wsgi "environment" is posing some limits ?

-- 
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.

Attachment: web2py.app.pyperf.tar.gz
Description: Binary data

import web
import time

urls = ("/pyperf", "welcome")
app = web.application(urls, globals())


class welcome:

    def GET(self):
        start = time.time()
        x = 0.0
        for i in range(1,50000):
            x += (float(i+10)*(i+25)+175.0)/3.14
        res = str(time.time()-start)
        return "elapsed time: "+ res + '\n'

if __name__ == "__main__":
    web.httpserver.runsimple(app.wsgifunc(), ("127.0.0.1", 8000))
import time
from flask import Flask
app = Flask(__name__)

@app.route("/pyperf")
def hello():
    start = time.time()
    x = 0.0
    for i in range(1,50000):
        x += (float(i+10)*(i+25)+175.0)/3.14
    res = str(time.time()-start)
    return "elapsed time: "+ res + '\n'

if __name__ == "__main__":
    app.run(port=8000)

Reply via email to