Try reloading a quick acting cgi page 100 times over. Thats where the diference lies.

On Tue, 20 Sep 2005, Gregor Horvath 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

benchmark script:
===========================================================================
#!/usr/bin/python

import urllib as u
import profile
import psycopg
import os


def testcgi():
   for i in range(100):
       u.urlopen("http://localhost/cgi-bin/perftestcgi.py";)

def testwebware():
   for i in range(100):
       u.urlopen("http://localhost/cgi-bin/WebKit.cgi/perftest.py";)

def testpsycopg():
   for i in range(100):
       c = psycopg.connect("dbname=timcos_0")
       os.popen2("python")
       c.close()

profile.run("testcgi()")

=====================================================================
The cgi script:
---------------

#!/usr/bin/python


import psycopg

print "content-type: text/html"
print

c = psycopg.connect("dbname=timcos_0")
cu = c.cursor()
cu.execute("select * from donework;")
r = cu.fetchall()
print("<html><body>%s</html></body>" % r)
c.close()

===================================================================
The webware servlet:
-------------------

#!/usr/bin/env python


from WebKit.Page import Page
import psycopg

class (Page):

   def __init__(self, *args, **KWs):

       print "INIT"
       Page.__init__(self, *args, **KWs)
       self.c = psycopg.connect("dbname=timcos_0")


   def writeBody(self):

       cu = self.c.cursor()
       cu.execute("select * from donework;")
       r = cu.fetchall()
       self.writeln("%s" % r)



--
Greg


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



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