Changes between Version 23 and Version 24 of DeveloperGuidelines/Optimisation
- Timestamp:
- 05/13/10 19:57:09 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Optimisation
v23 v24 3 3 Writing code which runs fast. 4 4 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) 5 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 6 around 600ms are totally acceptable (or a minor compared with the average download times on-site). 6 7 8 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. 9 10 Python Tips: 7 11 * http://wiki.python.org/moin/PythonSpeed/PerformanceTips 8 12 * http://www.python.org/doc/essays/list2str/ … … 11 15 * If a specific inner-loop routine cannot be optimised in Python, then consider writing a C routine for this use case. 12 16 17 Web2Py Tips: 13 18 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. 14 19 … … 23 28 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). 24 29 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) 32 31 33 32 === Specific Examples ===