Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5
Commits
13e4fe3a
Commit
13e4fe3a
authored
Sep 02, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testPerformance: support choosing between pprofile and cProfile
parent
18edf533
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
9 deletions
+26
-9
product/ERP5Type/tests/testPerformance.py
product/ERP5Type/tests/testPerformance.py
+26
-9
No files found.
product/ERP5Type/tests/testPerformance.py
View file @
13e4fe3a
...
...
@@ -110,8 +110,13 @@ LISTBOX_COEF=0.00173 # 0.02472
# LISTBOX_COEF : 0.02472 -> 0.001725
DO_TEST
=
1
# Profiler support.
# set 1 to get profiler's result (unit_test/tests/<func_name>)
PROFILE
=
0
PROFILE
=
0
# set this to 'pprofile' to profile with pprofile ( https://github.com/vpelletier/pprofile )
# instad of python's standard library profiler ( https://docs.python.org/2/library/profile.html )
PROFILER
=
'pprofile'
class
TestPerformanceMixin
(
ERP5TypeTestCase
,
LogInterceptor
):
...
...
@@ -147,22 +152,34 @@ class TestPerformanceMixin(ERP5TypeTestCase, LogInterceptor):
"""
return
self
.
portal
[
'bar_module'
]
def
profile
(
self
,
func
,
suffix
=
''
):
def
profile
(
self
,
func
,
suffix
=
''
,
args
=
(),
kw
=
None
):
"""Profile `func(*args, **kw)` with selected profiler,
and dump output in a file called `func.__name__ + suffix`
"""
if
not
kw
:
kw
=
{}
if
PROFILER
==
'pprofile'
:
import
pprofile
prof
=
pprofile
.
Profile
()
else
:
from
cProfile
import
Profile
prof_file
=
'%s%s'
%
(
func
.
__name__
,
suffix
)
try
:
os
.
unlink
(
prof_file
)
except
OSError
:
pass
prof
=
Profile
()
prof
.
runcall
(
func
)
prof
.
dump_stats
(
prof_file
)
prof_file
=
'%s%s'
%
(
func
.
__name__
,
suffix
)
try
:
os
.
unlink
(
prof_file
)
except
OSError
:
pass
prof
.
runcall
(
func
,
*
args
,
**
kw
)
prof
.
dump_stats
(
prof_file
)
def
beforeTearDown
(
self
):
# Re-enable gc at teardown.
gc
.
enable
()
self
.
abort
()
class
TestPerformance
(
TestPerformanceMixin
):
def
getTitle
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment