Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
4ecd85aa
Kaydet (Commit)
4ecd85aa
authored
Eyl 21, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
After the previous changes, func_normalize() turned out to be redundant.
This simplified some other places in the code.
üst
b0a94c05
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
60 deletions
+5
-60
profile.py
Lib/profile.py
+5
-60
No files found.
Lib/profile.py
Dosyayı görüntüle @
4ecd85aa
...
...
@@ -41,15 +41,6 @@ import string
import
marshal
# Global variables
func_norm_dict
=
{}
func_norm_counter
=
0
if
hasattr
(
os
,
'getpid'
):
pid_string
=
`os.getpid()`
else
:
pid_string
=
''
# Sample timer for use with
#i_count = 0
#def integer_timer():
...
...
@@ -126,15 +117,6 @@ def help():
# [5] = A dictionary indicating for each function name, the number of times
# it was called by us.
#**************************************************************************
# We produce function names via a repr() call on the f_code object during
# profiling. This save a *lot* of CPU time. This results in a string that
# always looks like:
# <code object main at 87090, file "/a/lib/python-local/myfib.py", line 76>
# After we "normalize it, it is a tuple of filename, line, function-name.
# We wait till we are done profiling to do the normalization.
# *IF* this repr format changes, then only the normalization routine should
# need to be fixed.
#**************************************************************************
class
Profile
:
def
__init__
(
self
,
timer
=
None
):
...
...
@@ -350,44 +332,11 @@ class Profile:
self
.
stats
=
{}
for
func
in
self
.
timings
.
keys
():
cc
,
ns
,
tt
,
ct
,
callers
=
self
.
timings
[
func
]
nor_func
=
self
.
func_normalize
(
func
)
nor_callers
=
{}
callers
=
callers
.
copy
()
nc
=
0
for
func_caller
in
callers
.
keys
():
nor_callers
[
self
.
func_normalize
(
func_caller
)]
=
\
callers
[
func_caller
]
nc
=
nc
+
callers
[
func_caller
]
self
.
stats
[
nor_func
]
=
cc
,
nc
,
tt
,
ct
,
nor_callers
# Override the following function if you can figure out
# a better name for the binary f_code entries. I just normalize
# them sequentially in a dictionary. It would be nice if we could
# *really* see the name of the underlying C code :-). Sometimes
# you can figure out what-is-what by looking at caller and callee
# lists (and knowing what your python code does).
def
func_normalize
(
self
,
func_name
):
global
func_norm_dict
global
func_norm_counter
global
func_sequence_num
if
func_norm_dict
.
has_key
(
func_name
):
return
func_norm_dict
[
func_name
]
if
type
(
func_name
)
==
type
(
""
):
long_name
=
string
.
split
(
func_name
)
file_name
=
long_name
[
-
3
][
1
:
-
2
]
func
=
long_name
[
2
]
lineno
=
long_name
[
-
1
][:
-
1
]
if
'?'
==
func
:
# Until I find out how to may 'em...
file_name
=
'python'
func_norm_counter
=
func_norm_counter
+
1
func
=
pid_string
+
".C."
+
`func_norm_counter`
result
=
file_name
,
string
.
atoi
(
lineno
)
,
func
else
:
result
=
func_name
func_norm_dict
[
func_name
]
=
result
return
result
self
.
stats
[
func
]
=
cc
,
nc
,
tt
,
ct
,
callers
# The following two methods can be called by clients to use
...
...
@@ -553,14 +502,11 @@ class OldProfile(Profile):
self
.
stats
=
{}
for
func
in
self
.
timings
.
keys
():
tt
,
ct
,
callers
=
self
.
timings
[
func
]
nor_func
=
self
.
func_normalize
(
func
)
nor_callers
=
{}
callers
=
callers
.
copy
()
nc
=
0
for
func_caller
in
callers
.
keys
():
nor_callers
[
self
.
func_normalize
(
func_caller
)]
=
\
callers
[
func_caller
]
nc
=
nc
+
callers
[
func_caller
]
self
.
stats
[
nor_func
]
=
nc
,
nc
,
tt
,
ct
,
nor_
callers
self
.
stats
[
func
]
=
nc
,
nc
,
tt
,
ct
,
callers
...
...
@@ -605,8 +551,7 @@ class HotProfile(Profile):
self
.
stats
=
{}
for
func
in
self
.
timings
.
keys
():
nc
,
tt
=
self
.
timings
[
func
]
nor_func
=
self
.
func_normalize
(
func
)
self
.
stats
[
nor_func
]
=
nc
,
nc
,
tt
,
0
,
{}
self
.
stats
[
func
]
=
nc
,
nc
,
tt
,
0
,
{}
...
...
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