Commit 21f7729f authored by Julien Muchembled's avatar Julien Muchembled

Clear transactional variables before testing views to make testPerformance more realistic

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32869 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0b7e1138
......@@ -33,6 +33,7 @@ import subprocess
import transaction
from DateTime import DateTime
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.utils import LogInterceptor
......@@ -180,9 +181,11 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
bar.setReference(bar.getRelativeUrl())
transaction.commit()
self.tic()
tv = getTransactionalVariable(None)
# Check performance
before_view = time()
for x in xrange(100):
tv.clear()
bar.Bar_viewPerformance()
after_view = time()
req_time = (after_view - before_view)/100.
......@@ -241,6 +244,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
view_result = {}
tic_result = {}
add_result = {}
tv = getTransactionalVariable(None)
# call view once to fill caches
self.bar_module.BarModule_viewBarList()
# add object in bar module
......@@ -266,6 +270,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
gc.collect()
before_form = time()
for x in xrange(100):
tv.clear()
self.bar_module.BarModule_viewBarList()
after_form = time()
# store result
......@@ -328,9 +333,11 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
title='Line 2')
transaction.commit()
self.tic()
tv = getTransactionalVariable(None)
# Check performance
before_view = time()
for x in xrange(100):
tv.clear()
foo.Foo_viewProxyField()
after_view = time()
req_time = (after_view - before_view)/100.
......@@ -361,9 +368,11 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
title='Line %s' % i)
transaction.commit()
self.tic()
tv = getTransactionalVariable(None)
# Check performance
before_view = time()
for x in xrange(100):
tv.clear()
foo.Foo_view()
after_view = time()
req_time = (after_view - before_view)/100.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment