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
466e6a90
Kaydet (Commit)
466e6a90
authored
Şub 07, 2012
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Have importlib.test.benchmark test with tabnanny as a medium-sized test.
üst
9878b63c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
32 deletions
+58
-32
benchmark.py
Lib/importlib/test/benchmark.py
+58
-32
No files found.
Lib/importlib/test/benchmark.py
Dosyayı görüntüle @
466e6a90
...
@@ -13,6 +13,7 @@ import json
...
@@ -13,6 +13,7 @@ import json
import
os
import
os
import
py_compile
import
py_compile
import
sys
import
sys
import
tabnanny
import
timeit
import
timeit
...
@@ -60,7 +61,7 @@ def builtin_mod(seconds, repeat):
...
@@ -60,7 +61,7 @@ def builtin_mod(seconds, repeat):
def
source_wo_bytecode
(
seconds
,
repeat
):
def
source_wo_bytecode
(
seconds
,
repeat
):
"""Source w/o bytecode: s
imple
"""
"""Source w/o bytecode: s
mall
"""
sys
.
dont_write_bytecode
=
True
sys
.
dont_write_bytecode
=
True
try
:
try
:
name
=
'__importlib_test_benchmark__'
name
=
'__importlib_test_benchmark__'
...
@@ -74,23 +75,30 @@ def source_wo_bytecode(seconds, repeat):
...
@@ -74,23 +75,30 @@ def source_wo_bytecode(seconds, repeat):
sys
.
dont_write_bytecode
=
False
sys
.
dont_write_bytecode
=
False
def
decimal_wo_bytecode
(
seconds
,
repeat
):
def
_wo_bytecode
(
module
):
"""Source w/o bytecode: decimal"""
name
=
module
.
__name__
name
=
'decimal'
def
benchmark_wo_bytecode
(
seconds
,
repeat
):
decimal_bytecode
=
imp
.
cache_from_source
(
decimal
.
__file__
)
"""Source w/o bytecode: {}"""
if
os
.
path
.
exists
(
decimal_bytecode
):
bytecode_path
=
imp
.
cache_from_source
(
module
.
__file__
)
os
.
unlink
(
decimal_bytecode
)
if
os
.
path
.
exists
(
bytecode_path
):
sys
.
dont_write_bytecode
=
True
os
.
unlink
(
bytecode_path
)
try
:
sys
.
dont_write_bytecode
=
True
for
result
in
bench
(
name
,
lambda
:
sys
.
modules
.
pop
(
name
),
repeat
=
repeat
,
try
:
seconds
=
seconds
):
for
result
in
bench
(
name
,
lambda
:
sys
.
modules
.
pop
(
name
),
yield
result
repeat
=
repeat
,
seconds
=
seconds
):
finally
:
yield
result
sys
.
dont_write_bytecode
=
False
finally
:
sys
.
dont_write_bytecode
=
False
benchmark_wo_bytecode
.
__doc__
=
benchmark_wo_bytecode
.
__doc__
.
format
(
name
)
return
benchmark_wo_bytecode
tabnanny_wo_bytecode
=
_wo_bytecode
(
tabnanny
)
decimal_wo_bytecode
=
_wo_bytecode
(
decimal
)
def
source_writing_bytecode
(
seconds
,
repeat
):
def
source_writing_bytecode
(
seconds
,
repeat
):
"""Source writing bytecode: s
imple
"""
"""Source writing bytecode: s
mall
"""
assert
not
sys
.
dont_write_bytecode
assert
not
sys
.
dont_write_bytecode
name
=
'__importlib_test_benchmark__'
name
=
'__importlib_test_benchmark__'
with
source_util
.
create_modules
(
name
)
as
mapping
:
with
source_util
.
create_modules
(
name
)
as
mapping
:
...
@@ -102,19 +110,27 @@ def source_writing_bytecode(seconds, repeat):
...
@@ -102,19 +110,27 @@ def source_writing_bytecode(seconds, repeat):
yield
result
yield
result
def
decimal_writing_bytecode
(
seconds
,
repeat
):
def
_writing_bytecode
(
module
):
"""Source writing bytecode: decimal"""
name
=
module
.
__name__
assert
not
sys
.
dont_write_bytecode
def
writing_bytecode_benchmark
(
seconds
,
repeat
):
name
=
'decimal'
"""Source writing bytecode: {}"""
def
cleanup
():
assert
not
sys
.
dont_write_bytecode
sys
.
modules
.
pop
(
name
)
def
cleanup
():
os
.
unlink
(
imp
.
cache_from_source
(
decimal
.
__file__
))
sys
.
modules
.
pop
(
name
)
for
result
in
bench
(
name
,
cleanup
,
repeat
=
repeat
,
seconds
=
seconds
):
os
.
unlink
(
imp
.
cache_from_source
(
module
.
__file__
))
yield
result
for
result
in
bench
(
name
,
cleanup
,
repeat
=
repeat
,
seconds
=
seconds
):
yield
result
writing_bytecode_benchmark
.
__doc__
=
(
writing_bytecode_benchmark
.
__doc__
.
format
(
name
))
return
writing_bytecode_benchmark
tabnanny_writing_bytecode
=
_writing_bytecode
(
tabnanny
)
decimal_writing_bytecode
=
_writing_bytecode
(
decimal
)
def
source_using_bytecode
(
seconds
,
repeat
):
def
source_using_bytecode
(
seconds
,
repeat
):
"""
Bytecode w/ source: simple
"""
"""
Source w/ bytecode: small
"""
name
=
'__importlib_test_benchmark__'
name
=
'__importlib_test_benchmark__'
with
source_util
.
create_modules
(
name
)
as
mapping
:
with
source_util
.
create_modules
(
name
)
as
mapping
:
py_compile
.
compile
(
mapping
[
name
])
py_compile
.
compile
(
mapping
[
name
])
...
@@ -124,13 +140,21 @@ def source_using_bytecode(seconds, repeat):
...
@@ -124,13 +140,21 @@ def source_using_bytecode(seconds, repeat):
yield
result
yield
result
def
decimal_using_bytecode
(
seconds
,
repeat
):
def
_using_bytecode
(
module
):
"""Bytecode w/ source: decimal"""
name
=
module
.
__name__
name
=
'decimal'
def
using_bytecode_benchmark
(
seconds
,
repeat
):
py_compile
.
compile
(
decimal
.
__file__
)
"""Source w/ bytecode: {}"""
for
result
in
bench
(
name
,
lambda
:
sys
.
modules
.
pop
(
name
),
repeat
=
repeat
,
py_compile
.
compile
(
module
.
__file__
)
seconds
=
seconds
):
for
result
in
bench
(
name
,
lambda
:
sys
.
modules
.
pop
(
name
),
repeat
=
repeat
,
yield
result
seconds
=
seconds
):
yield
result
using_bytecode_benchmark
.
__doc__
=
(
using_bytecode_benchmark
.
__doc__
.
format
(
name
))
return
using_bytecode_benchmark
tabnanny_using_bytecode
=
_using_bytecode
(
tabnanny
)
decimal_using_bytecode
=
_using_bytecode
(
decimal
)
def
main
(
import_
,
filename
=
None
,
benchmark
=
None
):
def
main
(
import_
,
filename
=
None
,
benchmark
=
None
):
...
@@ -143,6 +167,8 @@ def main(import_, filename=None, benchmark=None):
...
@@ -143,6 +167,8 @@ def main(import_, filename=None, benchmark=None):
benchmarks
=
(
from_cache
,
builtin_mod
,
benchmarks
=
(
from_cache
,
builtin_mod
,
source_using_bytecode
,
source_wo_bytecode
,
source_using_bytecode
,
source_wo_bytecode
,
source_writing_bytecode
,
source_writing_bytecode
,
tabnanny_using_bytecode
,
tabnanny_wo_bytecode
,
tabnanny_writing_bytecode
,
decimal_using_bytecode
,
decimal_writing_bytecode
,
decimal_using_bytecode
,
decimal_writing_bytecode
,
decimal_wo_bytecode
,)
decimal_wo_bytecode
,)
if
benchmark
:
if
benchmark
:
...
...
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