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 ...@@ -33,6 +33,7 @@ import subprocess
import transaction import transaction
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.utils import LogInterceptor from Products.ERP5Type.tests.utils import LogInterceptor
...@@ -180,10 +181,12 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -180,10 +181,12 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
bar.setReference(bar.getRelativeUrl()) bar.setReference(bar.getRelativeUrl())
transaction.commit() transaction.commit()
self.tic() self.tic()
tv = getTransactionalVariable(None)
# Check performance # Check performance
before_view = time() before_view = time()
for x in xrange(100): for x in xrange(100):
bar.Bar_viewPerformance() tv.clear()
bar.Bar_viewPerformance()
after_view = time() after_view = time()
req_time = (after_view - before_view)/100. req_time = (after_view - before_view)/100.
if not quiet: if not quiet:
...@@ -241,6 +244,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -241,6 +244,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
view_result = {} view_result = {}
tic_result = {} tic_result = {}
add_result = {} add_result = {}
tv = getTransactionalVariable(None)
# call view once to fill caches # call view once to fill caches
self.bar_module.BarModule_viewBarList() self.bar_module.BarModule_viewBarList()
# add object in bar module # add object in bar module
...@@ -266,6 +270,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -266,6 +270,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
gc.collect() gc.collect()
before_form = time() before_form = time()
for x in xrange(100): for x in xrange(100):
tv.clear()
self.bar_module.BarModule_viewBarList() self.bar_module.BarModule_viewBarList()
after_form = time() after_form = time()
# store result # store result
...@@ -328,9 +333,11 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -328,9 +333,11 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
title='Line 2') title='Line 2')
transaction.commit() transaction.commit()
self.tic() self.tic()
tv = getTransactionalVariable(None)
# Check performance # Check performance
before_view = time() before_view = time()
for x in xrange(100): for x in xrange(100):
tv.clear()
foo.Foo_viewProxyField() foo.Foo_viewProxyField()
after_view = time() after_view = time()
req_time = (after_view - before_view)/100. req_time = (after_view - before_view)/100.
...@@ -361,9 +368,11 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -361,9 +368,11 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
title='Line %s' % i) title='Line %s' % i)
transaction.commit() transaction.commit()
self.tic() self.tic()
tv = getTransactionalVariable(None)
# Check performance # Check performance
before_view = time() before_view = time()
for x in xrange(100): for x in xrange(100):
tv.clear()
foo.Foo_view() foo.Foo_view()
after_view = time() after_view = time()
req_time = (after_view - before_view)/100. 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