Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2abe785f
Commit
2abe785f
authored
Jan 09, 2005
by
Johannes Gijsbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move code in __name__ == '__main__' block into main() function, rewrite code so
there's no need to subclass OptionParser.
parent
97613ad0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
Lib/profile.py
Lib/profile.py
+14
-16
No files found.
Lib/profile.py
View file @
2abe785f
...
...
@@ -583,31 +583,29 @@ class Profile:
def
Stats
(
*
args
):
print
'Report generating functions are in the "pstats" module
\
a
'
# When invoked as main program, invoke the profiler on a script
if
__name__
==
'__main__'
:
def
main
():
usage
=
"profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
if
not
sys
.
argv
[
1
:]:
print
"Usage: "
,
usage
sys
.
exit
(
2
)
class
ProfileParser
(
OptionParser
):
def
__init__
(
self
,
usage
):
OptionParser
.
__init__
(
self
)
self
.
usage
=
usage
parser
=
ProfileParser
(
usage
)
parser
=
OptionParser
(
usage
=
usage
)
parser
.
allow_interspersed_args
=
False
parser
.
add_option
(
'-o'
,
'--outfile'
,
dest
=
"outfile"
,
help
=
"Save stats to <outfile>"
,
default
=
None
)
parser
.
add_option
(
'-s'
,
'--sort'
,
dest
=
"sort"
,
help
=
"Sort order when printing to stdout, based on pstats.Stats class"
,
default
=-
1
)
if
not
sys
.
argv
[
1
:]:
parser
.
print_usage
()
sys
.
exit
(
2
)
(
options
,
args
)
=
parser
.
parse_args
()
sys
.
argv
[:]
=
args
if
(
len
(
sys
.
argv
)
>
0
):
sys
.
path
.
insert
(
0
,
os
.
path
.
dirname
(
sys
.
argv
[
0
]))
run
(
'execfile(%r)'
%
(
sys
.
argv
[
0
],),
options
.
outfile
,
options
.
sort
)
else
:
print
"Usage: "
,
usage
parser
.
print_usage
()
return
parser
# When invoked as main program, invoke the profiler on a script
if
__name__
==
'__main__'
:
main
()
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