thanks for this test. Would you be able to also test them setting db.define_table(....,migrate=False)
? which is what people should do on production. Massimo On Aug 24, 5:07 am, what_ho <a...@viovi.com> wrote: > I did some quick and dirty performance tests to measure the time taken > by db.define_table calls. > > Test was as follows: > - Run web2py locally, with built-in web server > - Create new application 'perftest' in web2py admin interface > - Add 5 dummy table definitions to db.py, uncomment mail and auth > settings (see copy of my db.py at end of this message) > - Run the HP tool httperf to access perftest home page 1000 times > using the following command: > httperf --hog --server=localhost --port 8000 --uri /perftest/default/ > index --num-conns=1000 > - Time tests with db.py as defined below, with table definitions > removed, and with db.py file removed completely > > To remove the table definitions I commented out the line > 'auth.define_tables()' and all lines starting 'db.define_table' in > db.py > > For reference I am running Ubuntu Linux (karmic alpha), Intel Dual > Core 2.0Ghz, 4GB RAM. httperf version used is 0.9.0 (available from > synaptic package manager). web2py version 1.66.2, python 2.5 > > Results - time to receive 1000 pages from web2py built-in webserver: > > Not compiled: > Full db.py - 22.4s > No table defs in db.py - 11.5s > No db.py at all 9.6s > > Compiled: > Full db.py - 16s > No table defs - 5.7s > No db.py at all 4.1s > > This does appear to show there would be a performance benefit to > sharing the db object definitions between page requests. > > Yarko - I like your suggestion of putting table definitions in gluon > just as a quick hack to compare performance - I will try this next. > > Please find the source of the db.py file I used below: > > # coding: utf8 > > if request.env.web2py_runtime_gae: # if running on Google > App Engine > db = DAL('gae') # connect to Google > BigTable > session.connect(request, response, db=db) # and store sessions and > tickets there > else: # else use a normal > relational database > db = DAL('sqlite://storage.sqlite') # if not, use SQLite or > other DB > > from gluon.tools import * > auth=Auth(globals(),db) # authentication/ > authorization > auth.settings.hmac_key='6944f00d-1758-41e4-8fdb-625b0be17e1a' > auth.define_tables() # creates all needed > tables > crud=Crud(globals(),db) # for CRUD helpers using > auth > service=Service(globals()) # for json, xml, jsonrpc, > xmlrpc, amfrpc > crud.settings.auth=auth # enforces authorization > on crud > mail=Mail() # mailer > mail.settings.server='smtp.gmail.com:587' # your SMTP server > mail.settings.sender='....@gmail.com' # your email > mail.settings.login='username:password' # your credentials or > None > auth.settings.mailer=mail # for user email > verification > auth.settings.registration_requires_verification = True > auth.settings.registration_requires_approval = True > auth.messages.verify_email = \ > 'Click on the linkhttp://.../user/verify_email/%(key)sto verify > your email' > > db.define_table('perftest1', > SQLField('string1','string'), > SQLField('text1','text'), > SQLField('blob1','blob'), > SQLField('password1','password'), > SQLField('upload1','upload'), > SQLField('boolean1','boolean'), > SQLField('integer1','integer'), > SQLField('double1','double'), > SQLField('date1','date'), > SQLField('time1','time'), > SQLField('datetime1','datetime')) > > db.define_table('perftest2', > SQLField('string2','string'), > SQLField('text2','text'), > SQLField('blob2','blob'), > SQLField('password2','password'), > SQLField('upload2','upload'), > SQLField('boolean2','boolean'), > SQLField('integer2','integer'), > SQLField('double2','double'), > SQLField('date2','date'), > SQLField('time2','time'), > SQLField('datetime2','datetime')) > > db.define_table('perftest3', > SQLField('string3','string'), > SQLField('text3','text'), > SQLField('blob3','blob'), > SQLField('password3','password'), > SQLField('upload3','upload'), > SQLField('boolean3','boolean'), > SQLField('integer3','integer'), > SQLField('double3','double'), > SQLField('date3','date'), > SQLField('time3','time'), > SQLField('datetime3','datetime')) > > db.define_table('perftest4', > SQLField('string4','string'), > SQLField('text4','text'), > SQLField('blob4','blob'), > SQLField('password4','password'), > SQLField('upload4','upload'), > SQLField('boolean4','boolean'), > SQLField('integer4','integer'), > SQLField('double4','double'), > SQLField('date4','date'), > SQLField('time4','time'), > SQLField('datetime4','datetime')) > > db.define_table('perftest5', > SQLField('string5','string'), > SQLField('text5','text'), > SQLField('blob5','blob'), > SQLField('password5','password'), > SQLField('upload5','upload'), > SQLField('boolean5','boolean'), > SQLField('integer5','integer'), > SQLField('double5','double'), > SQLField('date5','date'), > SQLField('time5','time'), > SQLField('datetime5','datetime')) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---