Skip to content

Commit 7d66497

Browse files
authored
Include size of ww.js file in code size tests. NFC. (#21730)
1 parent cb158e3 commit 7d66497

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

test/code_size/hello_wasm_worker_wasm.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"a.html.gz": 433,
44
"a.js": 665,
55
"a.js.gz": 455,
6+
"a.ww.js": 115,
7+
"a.ww.js.gz": 127,
68
"a.wasm": 1852,
79
"a.wasm.gz": 1049,
8-
"total": 3254,
9-
"total_gz": 1937
10+
"total": 3369,
11+
"total_gz": 2064
1012
}

test/test_other.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10720,6 +10720,8 @@ def print_percent(actual, expected):
1072010720
return ' ({:+.2f}%)'.format((actual - expected) * 100.0 / expected)
1072110721

1072210722
outputs = ['a.html', 'a.js']
10723+
if '-sWASM_WORKERS' in sources:
10724+
outputs += ['a.ww.js']
1072310725

1072410726
args = smallest_code_size_args[:]
1072510727

tools/link.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ def fix_es6_import_statements(js_file):
20312031
save_intermediate('es6-module')
20322032

20332033

2034-
def create_worker_file(input_file, target_dir, output_file):
2034+
def create_worker_file(input_file, target_dir, output_file, options):
20352035
output_file = os.path.join(target_dir, output_file)
20362036
input_file = utils.path_from_root(input_file)
20372037
contents = shared.read_and_preprocess(input_file, expand_macros=True)
@@ -2044,6 +2044,8 @@ def create_worker_file(input_file, target_dir, output_file):
20442044
contents = building.acorn_optimizer(output_file, ['minifyWhitespace'], return_output=True)
20452045
write_file(output_file, contents)
20462046

2047+
tools.line_endings.convert_line_endings_in_file(output_file, os.linesep, options.output_eol)
2048+
20472049

20482050
@ToolchainProfiler.profile_block('final emitting')
20492051
def phase_final_emitting(options, state, target, wasm_target):
@@ -2054,15 +2056,15 @@ def phase_final_emitting(options, state, target, wasm_target):
20542056

20552057
target_dir = os.path.dirname(os.path.abspath(target))
20562058
if settings.PTHREADS:
2057-
create_worker_file('src/worker.js', target_dir, settings.PTHREAD_WORKER_FILE)
2059+
create_worker_file('src/worker.js', target_dir, settings.PTHREAD_WORKER_FILE, options)
20582060

20592061
# Deploy the Wasm Worker bootstrap file as an output file (*.ww.js)
20602062
if settings.WASM_WORKERS == 1:
2061-
create_worker_file('src/wasm_worker.js', target_dir, settings.WASM_WORKER_FILE)
2063+
create_worker_file('src/wasm_worker.js', target_dir, settings.WASM_WORKER_FILE, options)
20622064

20632065
# Deploy the Audio Worklet module bootstrap file (*.aw.js)
20642066
if settings.AUDIO_WORKLET == 1:
2065-
create_worker_file('src/audio_worklet.js', target_dir, settings.AUDIO_WORKLET_FILE)
2067+
create_worker_file('src/audio_worklet.js', target_dir, settings.AUDIO_WORKLET_FILE, options)
20662068

20672069
if settings.MODULARIZE:
20682070
modularize()

0 commit comments

Comments
 (0)