Changes between Version 23 and Version 24 of DeveloperGuidelines/Optimisation


Ignore:
Timestamp:
05/13/10 19:57:09 (15 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Optimisation

    v23 v24  
    33Writing code which runs fast.
    44
    5 Consider having configurations which are read from DB frequently but written-to rarely, be set in configuration files which are written-out from the DB (like the CSS from themes)
     5NB Performance is not everything, and you should not optimize any code without actually having a problem with it. In most cases, response times of
     6around 600ms are totally acceptable (or a minor compared with the average download times on-site).
    67
     8There are more things to consider besides performance, e.g. usability and maintainability of code. New contributors should be able to easily understand the code, and bugs should be easy to find.
     9
     10Python Tips:
    711 * http://wiki.python.org/moin/PythonSpeed/PerformanceTips
    812 * http://www.python.org/doc/essays/list2str/
     
    1115 * If a specific inner-loop routine cannot be optimised in Python, then consider writing a C routine for this use case.
    1216
     17Web2Py Tips:
    1318 1. Optimize the models, throw away what we don't need. Every field counts.[[BR]]Especially problematic in view of performance are references (joins), as they execute implicit DB requests. The more complex references are, the slower the model loads.
    1419
     
    2328 6. Python runs very fast as opposed to DB queries, so it can be much faster to retrieve 100 rows in one query and then drop 95 of them in the Python code, than to retrieve 5 rows in 5 queries (=do not loop over queries, better loop over the results).
    2429
    25 NB Performance is not everything, and you should not optimize any code without actually having a problem with it. In most cases, response times of
    26 around 600ms are totally acceptable (or a minor compared with the average download times on-site).
    27 
    28 There are more things to consider besides performance, e.g. usability and maintainability of code. New contributors should be able to easily understand the code, and bugs should be easy to find.
    29 
    30 Python performance tips:
    31  * http://wiki.python.org/moin/PythonSpeed/PerformanceTips
     30 7. Consider having configurations which are read from DB frequently but written-to rarely, be set in configuration files which are written-out from the DB (like the CSS from themes)
    3231
    3332=== Specific Examples ===