[FIX] base_module_quality: speed test if read method has exception
bzr revid: mra@tinyerp.com-20090922141447-e22fbytnhwtokuqs
This commit is contained in:
@@ -64,6 +64,9 @@ This test checks the speed of the module. Note that at least 5 demo data is need
|
||||
result_dict2 = {}
|
||||
self.result_details += _("<html>O(1) means that the number of SQL requests to read the object does not depand on the number of objects we are reading. This feature is hardly wished.\n</html>")
|
||||
for obj, ids in obj_ids.items():
|
||||
code_base_complexity = 0
|
||||
code_half_complexity = 0
|
||||
code_size_complexity = 0
|
||||
obj_counter += 1
|
||||
ids = ids[:100]
|
||||
size = len(ids)
|
||||
@@ -71,34 +74,38 @@ This test checks the speed of the module. Note that at least 5 demo data is need
|
||||
if size:
|
||||
speed_list = []
|
||||
#we perform the operation twice, and count the number of queries in the second run. This allows to avoid the cache effect. (like translated terms that asks for more queries)
|
||||
pool.get(obj).read(cr, uid, [ids[0]])
|
||||
cnt = cr.count
|
||||
pool.get(obj).read(cr, uid, [ids[0]])
|
||||
code_base_complexity = cr.count - cnt
|
||||
try:
|
||||
pool.get(obj).read(cr, uid, [ids[0]])
|
||||
cnt = cr.count
|
||||
pool.get(obj).read(cr, uid, [ids[0]])
|
||||
code_base_complexity = cr.count - cnt
|
||||
|
||||
pool.get(obj).read(cr, uid, ids[:size/2])
|
||||
cnt = cr.count
|
||||
pool.get(obj).read(cr, uid, ids[:size/2])
|
||||
code_half_complexity = cr.count - cnt
|
||||
pool.get(obj).read(cr, uid, ids[:size/2])
|
||||
cnt = cr.count
|
||||
pool.get(obj).read(cr, uid, ids[:size/2])
|
||||
code_half_complexity = cr.count - cnt
|
||||
|
||||
pool.get(obj).read(cr, uid, ids)
|
||||
cnt = cr.count
|
||||
pool.get(obj).read(cr, uid, ids)
|
||||
code_size_complexity = cr.count - cnt
|
||||
|
||||
if size < 5:
|
||||
speed_list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, _("Warning! Not enough demo data")]
|
||||
list2 = [obj, _("No enough data")]
|
||||
pool.get(obj).read(cr, uid, ids)
|
||||
cnt = cr.count
|
||||
pool.get(obj).read(cr, uid, ids)
|
||||
code_size_complexity = cr.count - cnt
|
||||
except Exception, e:
|
||||
list2 = [obj, _("Error in Read method")]
|
||||
speed_list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, _("Error in Read method:" + str(e))]
|
||||
else:
|
||||
if code_size_complexity <= (code_base_complexity + size):
|
||||
complexity = _("O(1)")
|
||||
score += 1
|
||||
list2 = [obj, _("Efficient")]
|
||||
if size < 5:
|
||||
speed_list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, _("Warning! Not enough demo data")]
|
||||
list2 = [obj, _("No enough data")]
|
||||
else:
|
||||
complexity = _("O(n) or worst")
|
||||
list2 = [obj, _("Not Efficient")]
|
||||
if code_size_complexity <= (code_base_complexity + size):
|
||||
complexity = _("O(1)")
|
||||
score += 1
|
||||
list2 = [obj, _("Efficient")]
|
||||
else:
|
||||
complexity = _("O(n) or worst")
|
||||
list2 = [obj, _("Not Efficient")]
|
||||
|
||||
speed_list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, complexity]
|
||||
speed_list = [obj, size, code_base_complexity, code_half_complexity, code_size_complexity, complexity]
|
||||
else:
|
||||
speed_list = [obj, size, "", "", "", _("Warning! Object has no demo data")]
|
||||
list2 = [obj, _("No data")]
|
||||
|
||||
Reference in New Issue
Block a user