Skip to content

Commit b36ae46

Browse files
authored
Merge pull request #93 from kurtmckee/plot-perf-test-windows
Update Windows performance testing to better match Linux
2 parents 519ae0f + eb9ce81 commit b36ae46

File tree

3 files changed

+37
-74
lines changed

3 files changed

+37
-74
lines changed

assets/test-performance.ps1

Lines changed: 36 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,57 @@
22
# Copyright 2024-2025 Kurt McKee <[email protected]>
33
# SPDX-License-Identifier: MIT
44

5-
$env:PYTHONPROFILEIMPORTTIME=$null
6-
$env:PYTHONDONTWRITEBYTECODE=1
7-
8-
Remove-Item -Recurse "build\perftest" | Out-Null
9-
Remove-Item perf.* | Out-Null
10-
python assets/generate-perftest-directory.py
11-
12-
# Note the size of the source code tree.
13-
Write-Output "Source tree" > perf.files.log
14-
Get-ChildItem -Recurse "build\perftest" | Measure-Object -Sum Length >> perf.files.log
15-
16-
17-
$env:PYTHONPROFILEIMPORTTIME=1
18-
$env:PYTHONDONTWRITEBYTECODE=1
5+
python assets/performance clean
6+
mkdir -p build/perfstats
7+
python assets/performance generate -r custom-requirements.txt
198

209

2110
# Filesystem -- source only
2211
# -------------------------
2312

2413
Write-Host
25-
$env:FILE_PREFIX="perf.filesystem.source"
26-
Write-Host "${env:FILE_PREFIX}"
27-
$env:PYTHONPATH="build\perftest"
28-
Measure-Command {
29-
python -c 'import a; print(a)' 2>"${env:FILE_PREFIX}.import.log" | Write-Host
30-
} > "${env:FILE_PREFIX}.time.log"
14+
Write-Host "filesystem / source"
15+
python assets/performance run --importer filesystem --code-type source importsy.py
3116

3217

3318
# Zip -- source only
3419
# ------------------
3520

3621
Write-Host
37-
$env:FILE_PREFIX="perf.zip.source"
38-
Write-Host "${env:FILE_PREFIX}"
39-
$env:PYTHONPATH="${env:FILE_PREFIX}.zip"
40-
Compress-Archive -CompressionLevel Optimal -Path "build\perftest\*" -DestinationPath "${env:PYTHONPATH}"
41-
Measure-Command {
42-
python -c 'import a; print(a)' 2>"${env:FILE_PREFIX}.import.log" | Write-Host
43-
} > "${env:FILE_PREFIX}.time.log"
22+
Write-Host "zipimport / source"
23+
$env:FILE_PREFIX="build\perfstats"
24+
$env:OUTPUT_PATH="${env:FILE_PREFIX}\source.zip"
25+
Compress-Archive -CompressionLevel Optimal -Path "build\perftest\*" -DestinationPath "${env:OUTPUT_PATH}"
26+
python assets/performance run --importer zipimport --code-type source importsy.py
4427

4528

4629

4730
# Sqlite -- source only
4831
# ---------------------
4932

5033
Write-Host
51-
$env:FILE_PREFIX="perf.sqlite.source"
52-
Write-Host "${env:FILE_PREFIX}"
53-
$env:PYTHONPATH="${env:FILE_PREFIX}.sqlite3"
54-
$env:PYTHONPROFILEIMPORTTIME=$null
55-
sqliteimport bundle "build\perftest" "${env:PYTHONPATH}" | Out-Null
56-
$env:PYTHONPROFILEIMPORTTIME=1
57-
Measure-Command {
58-
python -c 'import sqliteimport; import a; print(a)' 2> "${env:FILE_PREFIX}.import.log" | Write-Host
59-
} > "${env:FILE_PREFIX}.time.log"
34+
Write-Host "sqliteimport / source"
35+
$env:FILE_PREFIX="build\perfstats"
36+
$env:OUTPUT_PATH="${env:FILE_PREFIX}\source.sqlite3"
37+
sqliteimport bundle "build\perftest" "${env:OUTPUT_PATH}" | Out-Null
38+
python assets/performance run --importer sqliteimport --code-type source importsy.py
6039

6140

6241
# Compile the source to bytecode
6342
# ------------------------------
6443

65-
$env:PYTHONPROFILEIMPORTTIME=$null
66-
67-
# Compile into `__pycache__/` subdirectories for the filesystem.
68-
python -m compileall -q "build\perftest"
69-
70-
# Note the size of the tree, including bytecode.
71-
Write-Output "Source tree with bytecode" >> perf.files.log
72-
Get-ChildItem -Recurse "build\perftest" | Measure-Object -Sum Length >> perf.files.log
73-
74-
# Compile in-place for zipimport.
75-
python -m compileall -b -q "build\perftest"
76-
77-
$env:PYTHONPROFILEIMPORTTIME=1
44+
# Compile the source code to bytecode for each importer type.
45+
python assets/performance compile --importer filesystem | Out-Null
46+
python assets/performance compile --importer zipimport | Out-Null
47+
python assets/performance compile --importer sqliteimport | Out-Null
7848

7949

8050
# Filesystem -- bytecode
8151
# ----------------------
8252

8353
Write-Host
84-
$env:FILE_PREFIX="perf.filesystem.bytecode"
85-
Write-Host "${env:FILE_PREFIX}"
86-
$env:PYTHONPATH="build\perftest"
87-
Measure-Command {
88-
python -c 'import a; print(a)' 2>"${env:FILE_PREFIX}.import.log" | Write-Host
89-
} > "${env:FILE_PREFIX}.time.log"
54+
Write-Host "filesystem / bytecode"
55+
python assets/performance run --importer filesystem --code-type bytecode importsy.py
9056

9157

9258
# Zip -- bytecode
@@ -97,32 +63,29 @@ $cache_paths = Get-ChildItem -Recurse "build\perftest" | Where-Object { $_.Name
9763
Remove-Item -Recurse $cache_paths | Out-Null
9864

9965
Write-Host
100-
$env:FILE_PREFIX="perf.zip.bytecode"
101-
Write-Host "${env:FILE_PREFIX}"
102-
$env:PYTHONPATH="${env:FILE_PREFIX}.zip"
103-
Compress-Archive -CompressionLevel Optimal -Path "build\perftest\*" -DestinationPath "${env:PYTHONPATH}"
104-
Measure-Command {
105-
python -c 'import a; print(a)' 2>"${env:FILE_PREFIX}.import.log" | Write-Host
106-
} > "${env:FILE_PREFIX}.time.log"
66+
Write-Host "zipimport / bytecode"
67+
$env:FILE_PREFIX="build\perfstats"
68+
$env:OUTPUT_PATH="${env:FILE_PREFIX}\bytecode.zip"
69+
Compress-Archive -CompressionLevel Optimal -Path "build\perftest\*" -DestinationPath "${env:OUTPUT_PATH}"
70+
python assets/performance run --importer zipimport --code-type bytecode importsy.py
10771

10872

10973
# Sqlite -- bytecode
11074
# ------------------
11175

11276
Write-Host
113-
$env:FILE_PREFIX="perf.sqlite.bytecode"
114-
Write-Host "${env:FILE_PREFIX}"
115-
$env:PYTHONPATH="${env:FILE_PREFIX}.sqlite3"
116-
$env:PYTHONPROFILEIMPORTTIME=$null
117-
sqliteimport bundle "build\perftest" "${env:PYTHONPATH}" | Out-Null
118-
sqliteimport compile "${env:PYTHONPATH}"
119-
$env:PYTHONPROFILEIMPORTTIME=1
120-
Measure-Command {
121-
python -c 'import sqliteimport; import a; print(a)' 2> "${env:FILE_PREFIX}.import.log" | Write-Host
122-
} > "${env:FILE_PREFIX}.time.log"
77+
Write-Host "sqliteimport / bytecode"
78+
python assets/performance run --importer sqliteimport --code-type bytecode importsy.py
12379

12480

12581
# Capture the file sizes
12682
# ----------------------
12783

128-
Get-ChildItem perf.*.zip,perf.*.sqlite3 >> perf.files.log
84+
# Collect stats
85+
# -------------
86+
87+
python assets/performance collect
88+
python assets/performance plot --code-type source --measurement time --output build/perfstats/windows-source-time.png
89+
python assets/performance plot --code-type bytecode --measurement time --output build/perfstats/windows-bytecode-time.png
90+
python assets/performance plot --code-type source --measurement size --output build/perfstats/windows-source-size.png
91+
python assets/performance plot --code-type bytecode --measurement size --output build/perfstats/windows-bytecode-size.png

assets/test-performance.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -eu
77

88
python assets/performance clean
99
mkdir -p build/perfstats
10-
python assets/performance generate -r flows-requirements.txt
10+
python assets/performance generate -r custom-requirements.txt
1111

1212

1313
# Filesystem -- source only
File renamed without changes.

0 commit comments

Comments
 (0)