Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
da65d353
Commit
da65d353
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish the switch to named tuples
parent
84ae8cea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
27 deletions
+16
-27
src/Products/ZCatalog/plan.py
src/Products/ZCatalog/plan.py
+16
-27
No files found.
src/Products/ZCatalog/plan.py
View file @
da65d353
...
...
@@ -110,6 +110,8 @@ Duration = namedtuple('Duration', ['start', 'end'])
IndexMeasurement
=
namedtuple
(
'IndexMeasurement'
,
[
'name'
,
'duration'
,
'num'
])
Benchmark
=
namedtuple
(
'Benchmark'
,
[
'num'
,
'duration'
,
'hits'
])
RecentQuery
=
namedtuple
(
'RecentQuery'
,
[
'duration'
,
'details'
])
Report
=
namedtuple
(
'Report'
,
[
'hits'
,
'duration'
,
'last'
])
class
CatalogPlan
(
object
):
...
...
@@ -231,7 +233,7 @@ class CatalogPlan(object):
return
key
=
self
.
key
re
s
=
(
total
,
self
.
res
)
re
cent
=
RecentQuery
(
duration
=
total
,
details
=
self
.
res
)
reports_lock
.
acquire
()
try
:
...
...
@@ -242,9 +244,9 @@ class CatalogPlan(object):
if
previous
:
counter
,
mean
,
last
=
previous
mean
=
(
mean
*
counter
+
total
)
/
float
(
counter
+
1
)
reports
[
self
.
cid
][
key
]
=
(
counter
+
1
,
mean
,
res
)
reports
[
self
.
cid
][
key
]
=
Report
(
counter
+
1
,
mean
,
recent
)
else
:
reports
[
self
.
cid
][
key
]
=
(
1
,
total
,
res
)
reports
[
self
.
cid
][
key
]
=
Report
(
1
,
total
,
recent
)
finally
:
reports_lock
.
release
()
...
...
@@ -256,34 +258,21 @@ class CatalogPlan(object):
reports_lock
.
release
()
def
report
(
self
):
"""Returns a statistic report of catalog queries as list of dicts as
follows:
[{'query': <query_key>,
'counter': <hits>
'duration': <mean duration>,
'last': <details of recent query>,
},
...
]
<details of recent query> := {'duration': <duration of last query>,
'details': <duration of single indexes>,
}
"""Returns a statistic report of catalog queries as list of dicts.
The duration is provided in millisecond.
"""
rval
=
[]
for
k
,
v
in
reports
.
get
(
self
.
cid
,
{}).
items
():
for
key
,
report
in
reports
.
get
(
self
.
cid
,
{}).
items
():
last
=
report
.
last
info
=
{
'query'
:
k
,
'counter'
:
v
[
0
]
,
'duration'
:
v
[
1
]
*
1000
,
'last'
:
{
'duration'
:
v
[
2
][
0
]
*
1000
,
'details'
:
[
dict
(
id
=
i
.
name
,
duration
=
i
.
duration
*
1000
,
length
=
i
.
num
)
for
i
in
v
[
2
][
1
]
],
'query'
:
k
ey
,
'counter'
:
report
.
hits
,
'duration'
:
report
.
duration
*
1000
,
'last'
:
{
'duration'
:
last
.
duration
*
1000
,
'details'
:
[
dict
(
id
=
d
.
name
,
duration
=
d
.
duration
*
1000
,
length
=
d
.
num
)
for
d
in
last
.
details
],
},
}
rval
.
append
(
info
)
...
...
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