Skip to content

[test] Measure gzip sizes without metadata. NFC #24612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions test/code_size/audio_worklet_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 519,
"a.html.gz": 364,
"a.html.gz": 357,
"a.js": 3853,
"a.js.gz": 2050,
"a.js.gz": 2045,
"a.wasm": 1294,
"a.wasm.gz": 864,
"a.wasm.gz": 857,
"total": 5666,
"total_gz": 3278
"total_gz": 3259
}
8 changes: 4 additions & 4 deletions test/code_size/embind_hello_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 380,
"a.html.gz": 373,
"a.js": 7680,
"a.js.gz": 3363,
"a.js.gz": 3358,
"a.wasm": 7300,
"a.wasm.gz": 3348,
"a.wasm.gz": 3341,
"total": 15532,
"total_gz": 7091
"total_gz": 7072
}
8 changes: 4 additions & 4 deletions test/code_size/embind_val_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 380,
"a.html.gz": 373,
"a.js": 5748,
"a.js.gz": 2563,
"a.js.gz": 2558,
"a.wasm": 9101,
"a.wasm.gz": 4698,
"a.wasm.gz": 4691,
"total": 15401,
"total_gz": 7641
"total_gz": 7622
}
8 changes: 4 additions & 4 deletions test/code_size/hello_wasm_worker_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 519,
"a.html.gz": 364,
"a.html.gz": 357,
"a.js": 830,
"a.js.gz": 530,
"a.js.gz": 525,
"a.wasm": 1891,
"a.wasm.gz": 1082,
"a.wasm.gz": 1075,
"total": 3240,
"total_gz": 1976
"total_gz": 1957
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 454,
"a.html.gz": 328,
"a.html.gz": 321,
"a.js": 4386,
"a.js.gz": 2252,
"a.js.gz": 2247,
"a.wasm": 8286,
"a.wasm.gz": 5617,
"a.wasm.gz": 5610,
"total": 13126,
"total_gz": 8197
"total_gz": 8178
}
6 changes: 3 additions & 3 deletions test/code_size/hello_webgl2_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 262,
"a.html.gz": 255,
"a.js": 18078,
"a.js.gz": 9781,
"a.js.gz": 9776,
"total": 18424,
"total_gz": 10043
"total_gz": 10031
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 454,
"a.html.gz": 328,
"a.html.gz": 321,
"a.js": 3924,
"a.js.gz": 2092,
"a.js.gz": 2087,
"a.wasm": 8286,
"a.wasm.gz": 5617,
"a.wasm.gz": 5610,
"total": 12664,
"total_gz": 8037
"total_gz": 8018
}
6 changes: 3 additions & 3 deletions test/code_size/hello_webgl_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 262,
"a.html.gz": 255,
"a.js": 17605,
"a.js.gz": 9614,
"a.js.gz": 9609,
"total": 17951,
"total_gz": 9876
"total_gz": 9864
}
8 changes: 4 additions & 4 deletions test/code_size/hello_world_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 380,
"a.html.gz": 373,
"a.js": 287,
"a.js.gz": 247,
"a.js.gz": 242,
"a.wasm": 95,
"a.wasm.gz": 108,
"a.wasm.gz": 101,
"total": 934,
"total_gz": 735
"total_gz": 716
}
6 changes: 3 additions & 3 deletions test/code_size/hello_world_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 323,
"a.html.gz": 253,
"a.html.gz": 246,
"a.js": 965,
"a.js.gz": 593,
"a.js.gz": 588,
"total": 1288,
"total_gz": 846
"total_gz": 834
}
8 changes: 4 additions & 4 deletions test/code_size/math_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 380,
"a.html.gz": 373,
"a.js": 110,
"a.js.gz": 125,
"a.js.gz": 120,
"a.wasm": 2687,
"a.wasm.gz": 1658,
"a.wasm.gz": 1651,
"total": 3349,
"total_gz": 2163
"total_gz": 2144
}
4 changes: 2 additions & 2 deletions test/code_size/random_printf_wasm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a.html": 12515,
"a.html.gz": 6858,
"a.html.gz": 6851,
"total": 12515,
"total_gz": 6858
"total_gz": 6851
}
4 changes: 2 additions & 2 deletions test/code_size/random_printf_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a.html": 17233,
"a.html.gz": 7547,
"a.html.gz": 7540,
"total": 17233,
"total_gz": 7547
"total_gz": 7540
}
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8171
8162
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8160
8151
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9159
9150
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8119
8110
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8119
8110
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8023
8014
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9176
9167
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8171
8162
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3355
3346
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7485
7476
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2606
2597
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8319
8310
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2496
2487
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2157
2148
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2119
2110
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Os.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2119
2110
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Oz.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1921
1912
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11482
11473
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1508
1499
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_single_file.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3620
3611
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2119
2110
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1696
1687
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1727
1718
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2134
2125
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_grow.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2283
2274
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1997
1988
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_standalone.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1963
1954
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1719
1710
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1727
1718
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1727
1718
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_64.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1267
1258
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6614
6605
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_O1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1329
1320
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1197
1188
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1163
1154
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_Os.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1163
1154
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_Os_mr.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
307
298
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1147
1138
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_Oz.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1163
1154
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_esm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1249
1240
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3744
3735
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3950
3941
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1163
1154
17 changes: 6 additions & 11 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,10 @@ def llvm_nm(file):
return symbols


def get_file_gzipped_size(f):
f_gz = f + '.gz'
with gzip.open(f_gz, 'wb') as gzf:
gzf.write(read_binary(f))
size = os.path.getsize(f_gz)
delete_file(f_gz)
return size
def get_file_and_gz_sizes(f):
contents = read_binary(f)
gz_contents = gzip.compress(contents)
return len(contents), len(gz_contents)


def deminify_syms(names, minification_map):
Expand Down Expand Up @@ -9317,8 +9314,7 @@ def run_codesize_test(self, filename, cflags, check_funcs=True, check_full_js=Fa

self.run_process(build_cmd + ['--profiling-funcs', '--closure=1'])

js_size = os.path.getsize('a.out.js')
gz_size = get_file_gzipped_size('a.out.js')
js_size, gz_size = get_file_and_gz_sizes('a.out.js')
js_size_file = expected_basename + '.jssize'
gz_size_file = expected_basename + '.gzsize'
self.check_expected_size_in_file('js', js_size_file, js_size)
Expand Down Expand Up @@ -11961,8 +11957,7 @@ def print_percent(actual, expected):
f_gz = f + '.gz'
expected_size = expected_results[f] if f in expected_results else float('inf')
expected_size_gz = expected_results[f_gz] if f_gz in expected_results else float('inf')
size = os.path.getsize(f)
size_gz = get_file_gzipped_size(f)
size, size_gz = get_file_and_gz_sizes(f)

obtained_results[f] = size
obtained_results[f_gz] = size_gz
Expand Down