Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
89225b187eb8
Commit
c8ce3e3e
authored
Jan 08, 2009
by
Sylvain Thenault
Browse files
turn exlog into a cw-ctl command
parent
0c931b2e2a68
Changes
2
Hide whitespace changes
Inline
Side-by-side
devtools/devctl.py
View file @
89225b18
...
...
@@ -176,6 +176,7 @@ def _generate_schema_pot(w, vreg, schema, libschema=None, cube=None):
add_msg
(
w
,
'%s_description'
%
objid
)
add_msg
(
w
,
objid
)
done
.
add
(
objid
)
def
defined_in_library
(
libschema
,
etype
,
rtype
,
tetype
,
x
):
"""return true if the given relation definition exists in cubicweb's library"""
...
...
@@ -478,9 +479,54 @@ class NewCubeCommand(Command):
break
return
includes
class
ExamineLogCommand
(
Command
):
"""Examine a rql log file.
usage: python exlog.py < rql.log
will print out the following table
total execution time || number of occurences || rql query
sorted by descending total execution time
chances are the lines at the top are the ones that will bring
the higher benefit after optimisation. Start there.
"""
name
=
'exlog'
options
=
(
)
def
run
(
self
,
args
):
if
args
:
raise
BadCommandUsage
(
"no argument expected"
)
import
re
requests
=
{}
for
line
in
sys
.
stdin
:
if
not
' WHERE '
in
line
:
continue
#sys.stderr.write( line )
rql
,
time
=
line
.
split
(
'--'
)
rql
=
re
.
sub
(
"(
\'
\w+': \d*)"
,
''
,
rql
)
req
=
requests
.
setdefault
(
rql
,
[])
time
.
strip
()
chunks
=
time
.
split
()
cputime
=
float
(
chunks
[
-
3
])
req
.
append
(
cputime
)
stat
=
[]
for
rql
,
times
in
requests
.
items
():
stat
.
append
(
(
sum
(
times
),
len
(
times
),
rql
)
)
stat
.
sort
()
stat
.
reverse
()
for
time
,
occ
,
rql
in
stat
:
print
time
,
occ
,
rql
register_commands
((
UpdateCubicWebCatalogCommand
,
UpdateTemplateCatalogCommand
,
LiveServerCommand
,
NewCubeCommand
,
ExamineLogCommand
,
))
devtools/exlog.py
deleted
100644 → 0
View file @
0c931b2e
"""
usage: python exlog.py < rql.log
will print out the following table
total execution time || number of occurences || rql query
sorted by descending total execution time
chances are the lines at the top are the ones that will bring
the higher benefit after optimisation. Start there.
"""
import
sys
,
re
def
run
():
requests
=
{}
for
line
in
sys
.
stdin
:
if
not
' WHERE '
in
line
:
continue
#sys.stderr.write( line )
rql
,
time
=
line
.
split
(
'--'
)
rql
=
re
.
sub
(
"(
\'
\w+': \d*)"
,
''
,
rql
)
req
=
requests
.
setdefault
(
rql
,
[])
time
.
strip
()
chunks
=
time
.
split
()
cputime
=
float
(
chunks
[
-
3
])
req
.
append
(
cputime
)
stat
=
[]
for
rql
,
times
in
requests
.
items
():
stat
.
append
(
(
sum
(
times
),
len
(
times
),
rql
)
)
stat
.
sort
()
stat
.
reverse
()
for
time
,
occ
,
rql
in
stat
:
print
time
,
occ
,
rql
if
__name__
==
'__main__'
:
run
()
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