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
ccc22dba
Commit
ccc22dba
authored
Sep 08, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added profiling support.
parent
7cb9b668
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
156 additions
and
3 deletions
+156
-3
lib/python/App/ApplicationManager.py
lib/python/App/ApplicationManager.py
+18
-1
lib/python/App/profile.dtml
lib/python/App/profile.dtml
+74
-0
lib/python/ZPublisher/Publish.py
lib/python/ZPublisher/Publish.py
+64
-2
No files found.
lib/python/App/ApplicationManager.py
View file @
ccc22dba
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__doc__
=
"""System management components"""
__version__
=
'$Revision: 1.5
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
7
$'
[
11
:
-
2
]
import
sys
,
os
,
time
,
string
,
Globals
,
Acquisition
,
os
...
...
@@ -96,6 +96,7 @@ from OFS import SimpleItem
from
App.Dialogs
import
MessageDialog
from
Product
import
ProductFolder
from
version_txt
import
version_txt
from
cStringIO
import
StringIO
try
:
import
thread
except
:
get_ident
=
lambda
:
0
...
...
@@ -395,3 +396,19 @@ class ApplicationManager(Folder,CacheManager):
REQUEST
[
'RESPONSE'
].
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_main'
)
# Profiling support
manage_profile
=
HTMLFile
(
'profile'
,
globals
())
def
manage_profile_stats
(
self
,
sort
=
'time'
,
limit
=
200
):
"""Return profile data if available"""
stats
=
getattr
(
sys
,
'_ps_'
,
None
)
if
stats
is
None
:
return
None
output
=
StringIO
()
stdout
=
sys
.
stdout
sys
.
stdout
=
output
stats
.
strip_dirs
().
sort_stats
(
sort
).
print_stats
(
limit
)
sys
.
stdout
.
flush
()
sys
.
stdout
=
stdout
return
output
.
getvalue
()
lib/python/App/profile.dtml
0 → 100755
View file @
ccc22dba
<html>
<head>
<title>
Profiler Information
</title>
<style
type=
"text/css"
>
<!
--
.header
{
font-weight
:
bold
;
font-size
:
10pt
;
}
.cell
{
font-size
:
10pt
;
}
--
>
</style>
</head>
<body
bgcolor=
"#FFFFFF"
link=
"#000099"
vlink=
"#555555"
>
<!--#var manage_tabs-->
<h3>
Profile Information
</h3>
<p>
<!--#let sort="REQUEST.get('sort', 'time')"
limit="REQUEST.get('limit', 100)"
stats="manage_profile_stats(sort, limit)"-->
<!--#if stats-->
<form
action=
"<!--#var URL-->"
method=
"POST"
>
<table>
<tr>
<td><strong>
Sort
</strong>
:
<select
name=
"sort"
>
<!--#in "('time', 'cumulative', 'calls', 'pcalls',
'name', 'file', 'module', 'line',
'nfl', 'stdname')"-->
<option
value=
"<!--#var sequence-item-->"
<!
--#if
"
sort=
=_['sequence-item']"--
>
selected
<!--#/if-->
>
<!--#var
sequence-item-->
<!--#/in-->
</select>
</td>
<td><strong>
Limit
</strong>
:
<select
name=
"limit:int"
>
<!--#in "(100, 200, 300, 400, 500)"-->
<option
value=
"<!--#var sequence-item-->"
<!
--#if
"
limit=
=_['sequence-item']"--
>
selected
<!--#/if-->
>
<!--#var
sequence-item-->
<!--#/in-->
</select>
</td>
<td>
<input
type=
"submit"
name=
"submit"
value=
"Update"
>
</td>
</tr>
</table>
</form>
<hr>
<pre>
<!--#var stats-->
</pre>
<!--#else-->
<em>
Profiling is not currently enabled or there is not yet any profiling
data to report. To enable profiling, restart the Zope process with
the environment variable PROFILE_PUBLISHER defined. The value of this
variable should be the full system path to a file that will be used
to dump a profile report when the process restarts or exits.
</em>
<!--#/if-->
<!--#/let-->
</body>
</html>
lib/python/ZPublisher/Publish.py
View file @
ccc22dba
...
...
@@ -84,8 +84,8 @@
##############################################################################
__doc__
=
"""Python Object Publisher -- Publish Python objects on web servers
$Id: Publish.py,v 1.14
1 1999/09/01 14:51:33 jim
Exp $"""
__version__
=
'$Revision: 1.14
1
$'
[
11
:
-
2
]
$Id: Publish.py,v 1.14
2 1999/09/08 14:52:07 brian
Exp $"""
__version__
=
'$Revision: 1.14
2
$'
[
11
:
-
2
]
import
sys
,
os
from
string
import
lower
,
atoi
,
rfind
,
strip
...
...
@@ -317,3 +317,65 @@ def get_module_info(module_name, modules={},
finally
:
tb
=
None
release
()
# ZPublisher profiler support
# ---------------------------
if
os
.
environ
.
get
(
'PROFILE_PUBLISHER'
,
None
):
import
profile
,
pstats
_pfile
=
os
.
environ
[
'PROFILE_PUBLISHER'
]
_plock
=
allocate_lock
()
_pfunc
=
publish_module
_pstat
=
None
def
pm
(
module_name
,
stdin
,
stdout
,
stderr
,
environ
,
debug
,
request
,
response
):
try
:
r
=
_pfunc
(
module_name
,
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
stderr
,
environ
=
environ
,
debug
=
debug
,
request
=
request
,
response
=
response
)
except
:
r
=
None
sys
.
_pr_
=
r
def
publish_module
(
module_name
,
stdin
=
sys
.
stdin
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
,
environ
=
os
.
environ
,
debug
=
0
,
request
=
None
,
response
=
None
):
_plock
.
acquire
()
try
:
if
request
is
not
None
:
path_info
=
request
.
get
(
'PATH_INFO'
)
else
:
path_info
=
environ
.
get
(
'PATH_INFO'
)
if
path_info
[
-
14
:]
==
'manage_profile'
:
return
_pfunc
(
module_name
,
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
stderr
,
environ
=
environ
,
debug
=
debug
,
request
=
request
,
response
=
response
)
pobj
=
profile
.
Profile
()
pobj
.
runcall
(
pm
,
module_name
,
stdin
,
stdout
,
stderr
,
environ
,
debug
,
request
,
response
)
result
=
sys
.
_pr_
pobj
.
create_stats
()
if
_pstat
is
None
:
global
_pstat
_pstat
=
sys
.
_ps_
=
pstats
.
Stats
(
pobj
)
else
:
_pstat
.
add
(
pobj
)
finally
:
_plock
.
release
()
if
result
is
None
:
try
:
error
=
sys
.
exc_info
()
file
=
open
(
_pfile
,
'w'
)
sys
.
stdout
=
file
_pstat
.
strip_dirs
().
sort_stats
(
'cumulative'
).
print_stats
(
250
)
_pstat
.
strip_dirs
().
sort_stats
(
'time'
).
print_stats
(
250
)
file
.
flush
()
file
.
close
()
except
:
pass
raise
error
[
0
],
error
[
1
],
error
[
2
]
return
result
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