On 9/19/05, Gregor Horvath <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I am evaluationg using Webware instead of plain python CGI.
> I therefore run some benchmark tests, and discovered that there is no
> difference in time needed between the webware and the cgi script.
> I am a little bit surprised, because I thought webware must be
> theoretically faster, because of the cached database connection and the
> interpreter startup overhead with cgi.
> Do you have a explanantion for that? Are my benchmarks wrong, or is it
> just the thruth that under this circumstances cgi is as fast as webware.
> 
> Python 2.2, Apache, Linux Redhat 9 (2.4.20), WebWare 0.81, Single
> Processor P4, 500 MB RAM
> 
> Running the benchmak script, profile says for testwebware:
> 
>   55254 function calls (55219 primitive calls) in 0.760 CPU seconds
> 
> and testcgi:
> 
>   54505 function calls in 0.800 CPU seconds
> 
> Running testpsycopg says:
> 
> 5356 function calls in 0.380 CPU seconds

I tested WebKit vs. CGI a long time ago and got a *huge* speed up due
to CGI's overhead such as:
- launching the Python interpreter as a new process
- importing various modules (sys, time, os, cgi, etc.)

I didn't measure in CPU seconds for function calls. I measured in
requests per seconds.

I got an even bigger speed boost when there was any configurations,
database records or computed values that I could cache (and there
often are).

Some thoughts on your speed test:

- There is very little Python code in the CGI script or servlet. My
own web apps have plenty of Python code to put the page together, so
if I was testing I would try something that looks more typical.

- I trust the profile module to help me locate bottlenecks in my
Python code, but for speed tests like this I prefer wall time:
(untested)

import time

def durationOf(run, iterations=1000):  # notice bigger range
    r = range(iterations)
    start = time.time()
    for i in r:
        # multiple calls to reduce overhead from "for"
        run()
        run()
        run()
        run()
        run()
        run()
        run()
        run()
        run()
        run()
    duration = time.time() - start
    print 'duration of %s is %s' % (run, duration)
    return duration

def this():
    ...

def that():
    ...

durationOf(this)
durationOf(that)

Also, exit email, exit all web browsers and shut down as many other
programs as possible before running.

What kind of results do you get then?


-Chuck


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to