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
dfc32706
Kaydet (Commit)
dfc32706
authored
Şub 24, 2012
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make the benchmark recording more sensible for importlib.test.benchmark.
üst
dcb30cf9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
29 deletions
+27
-29
benchmark.py
Lib/importlib/test/benchmark.py
+27
-29
No files found.
Lib/importlib/test/benchmark.py
Dosyayı görüntüle @
dfc32706
...
...
@@ -157,10 +157,10 @@ tabnanny_using_bytecode = _using_bytecode(tabnanny)
decimal_using_bytecode
=
_using_bytecode
(
decimal
)
def
main
(
import_
,
filename
=
None
,
benchmark
=
None
):
if
filename
and
os
.
path
.
exists
(
filename
)
:
with
op
en
(
filename
,
'r'
)
as
file
:
prev_results
=
json
.
load
(
file
)
def
main
(
import_
,
options
):
if
options
.
source_file
:
with
op
tions
.
source_
file
:
prev_results
=
json
.
load
(
options
.
source_
file
)
else
:
prev_results
=
{}
__builtins__
.
__import__
=
import_
...
...
@@ -172,13 +172,14 @@ def main(import_, filename=None, benchmark=None):
decimal_writing_bytecode
,
decimal_wo_bytecode
,
decimal_using_bytecode
,
)
if
benchmark
:
if
options
.
benchmark
:
for
b
in
benchmarks
:
if
b
.
__doc__
==
benchmark
:
if
b
.
__doc__
==
options
.
benchmark
:
benchmarks
=
[
b
]
break
else
:
print
(
'Unknown benchmark: {!r}'
.
format
(
benchmark
,
file
=
sys
.
stderr
))
print
(
'Unknown benchmark: {!r}'
.
format
(
options
.
benchmark
,
file
=
sys
.
stderr
))
sys
.
exit
(
1
)
seconds
=
1
seconds_plural
=
's'
if
seconds
>
1
else
''
...
...
@@ -200,22 +201,19 @@ def main(import_, filename=None, benchmark=None):
assert
not
sys
.
dont_write_bytecode
print
(
"]"
,
"best is"
,
format
(
max
(
results
),
',d'
))
new_results
[
benchmark
.
__doc__
]
=
results
prev_results
[
import_
.
__module__
]
=
new_results
if
'importlib._bootstrap'
in
prev_results
and
'builtins'
in
prev_results
:
print
(
'
\n\n
Comparing importlib vs. __import__
\n
'
)
importlib_results
=
prev_results
[
'importlib._bootstrap'
]
builtins_results
=
prev_results
[
'builtins'
]
if
prev_results
:
print
(
'
\n\n
Comparing new vs. old
\n
'
)
for
benchmark
in
benchmarks
:
benchmark_name
=
benchmark
.
__doc__
importlib_result
=
max
(
importlib
_results
[
benchmark_name
])
builtins_result
=
max
(
builtins
_results
[
benchmark_name
])
result
=
'{:,d} vs. {:,d} ({:
%
})'
.
format
(
importlib
_result
,
builtins
_result
,
importlib_result
/
builtins
_result
)
old_result
=
max
(
prev
_results
[
benchmark_name
])
new_result
=
max
(
new
_results
[
benchmark_name
])
result
=
'{:,d} vs. {:,d} ({:
%
})'
.
format
(
new
_result
,
old
_result
,
new_result
/
old
_result
)
print
(
benchmark_name
,
':'
,
result
)
if
filenam
e
:
with
op
en
(
filename
,
'w'
)
as
file
:
json
.
dump
(
prev_results
,
file
,
indent
=
2
)
if
options
.
dest_fil
e
:
with
op
tions
.
dest_
file
:
json
.
dump
(
new_results
,
options
.
dest_
file
,
indent
=
2
)
if
__name__
==
'__main__'
:
...
...
@@ -224,18 +222,18 @@ if __name__ == '__main__':
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-b'
,
'--builtin'
,
dest
=
'builtin'
,
action
=
'store_true'
,
default
=
False
,
help
=
"use the built-in __import__"
)
parser
.
add_argument
(
'-f'
,
'--file'
,
dest
=
'filename'
,
default
=
None
,
help
=
'file to read/write results from/to'
'(incompatible w/ --benchmark)'
)
parser
.
add_argument
(
'-r'
,
'--read'
,
dest
=
'source_file'
,
type
=
argparse
.
FileType
(
'r'
),
help
=
'file to read benchmark data from to compare '
'against'
)
parser
.
add_argument
(
'-w'
,
'--write'
,
dest
=
'dest_file'
,
type
=
argparse
.
FileType
(
'w'
),
help
=
'file to write benchmark data to'
)
parser
.
add_argument
(
'--benchmark'
,
dest
=
'benchmark'
,
help
=
'specific benchmark to run '
'(incompatible w/ --file)'
)
help
=
'specific benchmark to run'
)
options
=
parser
.
parse_args
()
if
options
.
filename
and
options
.
benchmark
:
print
(
'Cannot specify a benchmark *and* read/write results'
)
sys
.
exit
(
1
)
import_
=
__import__
if
not
options
.
builtin
:
import_
=
importlib
.
__import__
main
(
import_
,
options
.
filename
,
options
.
benchmark
)
main
(
import_
,
options
)
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