Skip to content

Commit 90cb70e

Browse files
authored
Add test_unoptimized_code_size. NFC (#17359)
I think its useful to have at least one test that tracks unoptimzed code size. If it fails to frequently we can increase the acceptable margin of error.
1 parent 697c3d9 commit 90cb70e

5 files changed

+24
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
89932
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12118
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
59666
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11607

tests/test_other.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7405,6 +7405,26 @@ def check_expected_size_in_file(self, desc, filename, size):
74057405
print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio))
74067406
self.assertLess(ratio, size_slack)
74077407

7408+
def test_unoptimized_code_size(self):
7409+
# We don't care too about unoptimized code size but we would like to keep it
7410+
# under control to a certain extent. This test allows us to track major
7411+
# changes to the size of the unoptimized and unminified code size.
7412+
# Run with `--rebase` when this test fails.
7413+
self.build(test_file('hello_world.c'), emcc_args=['-O0'])
7414+
self.build(test_file('hello_world.c'), emcc_args=['-O0', '-sASSERTIONS=0'], output_basename='no_asserts')
7415+
self.check_expected_size_in_file('wasm',
7416+
test_file('other/test_unoptimized_code_size.wasm.size'),
7417+
os.path.getsize('hello_world.wasm'))
7418+
self.check_expected_size_in_file('wasm',
7419+
test_file('other/test_unoptimized_code_size_no_asserts.wasm.size'),
7420+
os.path.getsize('no_asserts.wasm'))
7421+
self.check_expected_size_in_file('js',
7422+
test_file('other/test_unoptimized_code_size.js.size'),
7423+
os.path.getsize('hello_world.js'))
7424+
self.check_expected_size_in_file('js',
7425+
test_file('other/test_unoptimized_code_size_no_asserts.js.size'),
7426+
os.path.getsize('no_asserts.js'))
7427+
74087428
def run_metadce_test(self, filename, args=[], expected_exists=[], expected_not_exists=[], check_size=True, # noqa
74097429
check_sent=True, check_imports=True, check_exports=True, check_funcs=True):
74107430

0 commit comments

Comments
 (0)