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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
a27d06f8
Commit
a27d06f8
authored
Apr 13, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip log timings
parent
1737f9e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
33 deletions
+75
-33
product/ERP5Type/dynamic/lazy_class.py
product/ERP5Type/dynamic/lazy_class.py
+28
-6
product/ERP5Type/dynamic/portal_type_class.py
product/ERP5Type/dynamic/portal_type_class.py
+47
-27
No files found.
product/ERP5Type/dynamic/lazy_class.py
View file @
a27d06f8
...
@@ -20,6 +20,26 @@ from accessor_holder import AccessorHolderType
...
@@ -20,6 +20,26 @@ from accessor_holder import AccessorHolderType
import
persistent_migration
import
persistent_migration
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
contextlib
import
contextmanager
import
time
import
logging
@
contextmanager
def
_log_time_usage
(
prefix
=
""
):
'''log the time usage in a code block
prefix: the prefix text to show
'''
start
=
time
.
time
()
try
:
yield
finally
:
end
=
time
.
time
()
elapsed_seconds
=
float
(
"%.4f"
%
(
end
-
start
))
if
elapsed_seconds
>
0.5
:
logging
.
critical
(
'%s: elapsed seconds: %s'
,
prefix
,
elapsed_seconds
)
logging
.
info
(
'%s: elapsed seconds: %s'
,
prefix
,
elapsed_seconds
)
class
ERP5BaseBroken
(
Broken
,
ERP5Base
,
PersistentBroken
):
class
ERP5BaseBroken
(
Broken
,
ERP5Base
,
PersistentBroken
):
# PersistentBroken can't be reused directly
# PersistentBroken can't be reused directly
# because its « layout differs from 'GhostPortalType' »
# because its « layout differs from 'GhostPortalType' »
...
@@ -269,6 +289,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
...
@@ -269,6 +289,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
return
getattr
(
cls
.
__bases__
[
0
],
name
)
return
getattr
(
cls
.
__bases__
[
0
],
name
)
if
not
name
.
startswith
(
'__'
)
and
cls
.
__isghost__
:
if
not
name
.
startswith
(
'__'
)
and
cls
.
__isghost__
:
with
_log_time_usage
(
'loadClass (%s)'
%
cls
):
cls
.
loadClass
()
cls
.
loadClass
()
return
getattr
(
cls
,
name
)
return
getattr
(
cls
,
name
)
...
@@ -297,6 +318,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
...
@@ -297,6 +318,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
# generate all methods on Base accessor holder, with all methods
# generate all methods on Base accessor holder, with all methods
# returning False, and redefine on portal types only those returning True,
# returning False, and redefine on portal types only those returning True,
# aka only those for the group they belong to
# aka only those for the group they belong to
if
1
:
#with _log_time_usage("generating isAccessors for %s" % cls):
for
group
in
ERP5TypeInformation
.
defined_group_list
:
for
group
in
ERP5TypeInformation
.
defined_group_list
:
value
=
cls
.
__name__
in
site
.
_getPortalGroupedTypeSet
(
group
)
value
=
cls
.
__name__
in
site
.
_getPortalGroupedTypeSet
(
group
)
accessor_name
=
'is'
+
UpperCase
(
group
)
+
'Type'
accessor_name
=
'is'
+
UpperCase
(
group
)
+
'Type'
...
...
product/ERP5Type/dynamic/portal_type_class.py
View file @
a27d06f8
...
@@ -348,6 +348,24 @@ def generatePortalTypeClass(site, portal_type_name):
...
@@ -348,6 +348,24 @@ def generatePortalTypeClass(site, portal_type_name):
interface_class_list
,
interface_class_list
,
attribute_dict
)
attribute_dict
)
from
contextlib
import
contextmanager
import
time
import
logging
@
contextmanager
def
_log_time_usage
(
prefix
=
""
):
'''log the time usage in a code block
prefix: the prefix text to show
'''
start
=
time
.
time
()
try
:
yield
finally
:
end
=
time
.
time
()
elapsed_seconds
=
float
(
"%.4f"
%
(
end
-
start
))
logging
.
info
(
'%s: elapsed seconds: %s'
,
prefix
,
elapsed_seconds
)
def
loadTempPortalTypeClass
(
portal_type_name
):
def
loadTempPortalTypeClass
(
portal_type_name
):
"""
"""
Returns a class suitable for a temporary portal type
Returns a class suitable for a temporary portal type
...
@@ -463,6 +481,8 @@ def synchronizeDynamicModules(context, force=False):
...
@@ -463,6 +481,8 @@ def synchronizeDynamicModules(context, force=False):
LOG
(
"ERP5Type.dynamic"
,
0
,
"Resetting dynamic classes"
)
LOG
(
"ERP5Type.dynamic"
,
0
,
"Resetting dynamic classes"
)
try
:
try
:
with
_log_time_usage
(
"Resetting dynamic classes"
):
for
_
,
klass
in
inspect
.
getmembers
(
erp5
.
portal_type
,
for
_
,
klass
in
inspect
.
getmembers
(
erp5
.
portal_type
,
inspect
.
isclass
):
inspect
.
isclass
):
# Zope Interface is implemented through __implements__,
# Zope Interface is implemented through __implements__,
...
...
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