On 9/19/05, Gregor Horvath <g.horvath@...> wrote:
> 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
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:
def durationOf(run, iterations=3D1000): # notice bigger range
r =3D range(iterations)
start =3D time.time()
for i in r:
# multiple calls to reduce overhead from "for"
duration =3D time.time() - start
print 'duration of %s is %s' % (run, duration)
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?