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
810c64df
Kaydet (Commit)
810c64df
authored
May 11, 2012
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #14764: Update importlib.test.benchmark to work in a world where
import machinery is no longer implicit.
üst
9d335113
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
benchmark.py
Lib/importlib/test/benchmark.py
+14
-0
No files found.
Lib/importlib/test/benchmark.py
Dosyayı görüntüle @
810c64df
...
...
@@ -9,6 +9,8 @@ from .source import util as source_util
import
decimal
import
imp
import
importlib
import
importlib._bootstrap
import
importlib.machinery
import
json
import
os
import
py_compile
...
...
@@ -68,6 +70,10 @@ def source_wo_bytecode(seconds, repeat):
# Clears out sys.modules and puts an entry at the front of sys.path.
with
source_util
.
create_modules
(
name
)
as
mapping
:
assert
not
os
.
path
.
exists
(
imp
.
cache_from_source
(
mapping
[
name
]))
sys
.
meta_path
.
append
(
importlib
.
machinery
.
PathFinder
)
loader
=
(
importlib
.
machinery
.
SourceFileLoader
,
importlib
.
_bootstrap
.
_SOURCE_SUFFIXES
,
True
)
sys
.
path_hooks
.
append
(
importlib
.
machinery
.
FileFinder
.
path_hook
(
loader
))
for
result
in
bench
(
name
,
lambda
:
sys
.
modules
.
pop
(
name
),
repeat
=
repeat
,
seconds
=
seconds
):
yield
result
...
...
@@ -102,6 +108,10 @@ def source_writing_bytecode(seconds, repeat):
assert
not
sys
.
dont_write_bytecode
name
=
'__importlib_test_benchmark__'
with
source_util
.
create_modules
(
name
)
as
mapping
:
sys
.
meta_path
.
append
(
importlib
.
machinery
.
PathFinder
)
loader
=
(
importlib
.
machinery
.
SourceFileLoader
,
importlib
.
_bootstrap
.
_SOURCE_SUFFIXES
,
True
)
sys
.
path_hooks
.
append
(
importlib
.
machinery
.
FileFinder
.
path_hook
(
loader
))
def
cleanup
():
sys
.
modules
.
pop
(
name
)
os
.
unlink
(
imp
.
cache_from_source
(
mapping
[
name
]))
...
...
@@ -133,6 +143,10 @@ def source_using_bytecode(seconds, repeat):
"""Source w/ bytecode: small"""
name
=
'__importlib_test_benchmark__'
with
source_util
.
create_modules
(
name
)
as
mapping
:
sys
.
meta_path
.
append
(
importlib
.
machinery
.
PathFinder
)
loader
=
(
importlib
.
machinery
.
SourceFileLoader
,
importlib
.
_bootstrap
.
_SOURCE_SUFFIXES
,
True
)
sys
.
path_hooks
.
append
(
importlib
.
machinery
.
FileFinder
.
path_hook
(
loader
))
py_compile
.
compile
(
mapping
[
name
])
assert
os
.
path
.
exists
(
imp
.
cache_from_source
(
mapping
[
name
]))
for
result
in
bench
(
name
,
lambda
:
sys
.
modules
.
pop
(
name
),
repeat
=
repeat
,
...
...
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