Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyperformance/data-files/benchmarks/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ sqlglot_v2_parse <local:sqlglot_v2>
sqlglot_v2_transpile <local:sqlglot_v2>
sqlglot_v2_optimize <local:sqlglot_v2>
sqlite_synth <local>
stdlib_startup <local>
sympy <local>
telco <local>
tomli_loads <local>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "pyperformance_stdlib_startup"
requires-python = ">=3.10"
dependencies = []
urls = {repository = "https://github.com/python/pyperformance"}
dynamic = ["version"]

[tool.pyperformance]
name = "stdlib_startup"
tags = "startup"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
Comment thread
StanFromIreland marked this conversation as resolved.
import sys
import subprocess
import tempfile

import pyperf

if __name__ == "__main__":
runner = pyperf.Runner(values=10)

runner.metadata['description'] = "Performance of importing standard library modules"
args = runner.parse_args()

with tempfile.TemporaryDirectory() as tmp:
main = os.path.join(tmp, "main.py")
with open(main, "w") as f:
f.write("""
import importlib
import sys
for m in sys.stdlib_module_names:
if m in {"antigravity", "this"}:
continue
try:
importlib.import_module(m)
except ImportError:
pass
""")
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
command = [sys.executable, main]
runner.bench_command('stdlib_startup', command)
Loading