MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / print_sizes

Function print_sizes

emsize.py:47–77  ·  view source on GitHub ↗
(js_file)

Source from the content-addressed store, hash-verified

45
46
47def print_sizes(js_file):
48 if not os.path.isfile(js_file):
49 return error('Input JS file %s not found' % js_file)
50 if not js_file.endswith('.js'):
51 return error('Input file %s does not have a JS extension' % js_file)
52
53 basename = js_file[:-3]
54
55 # Find the JS file size
56 st = os.stat(js_file)
57 js_size = st.st_size
58
59 # Find the rest of the sizes
60 wasm_file = basename + '.wasm'
61 if not os.path.isfile(wasm_file):
62 return error('Wasm file %s not found' % wasm_file)
63
64 sizes = shared.check_call([LLVM_SIZE, '--format=sysv', wasm_file],
65 stdout=subprocess.PIPE).stdout
66 # llvm-size may emit some number of blank lines (after the total), ignore them
67 lines = [line for line in sizes.splitlines() if line]
68
69 # Last line is the total. Add the JS size.
70 total = int(lines[-1].split()[-1])
71 total += js_size
72
73 for line in lines[:-1]:
74 print(line)
75
76 print('JS\t\t%s\t0' % js_size)
77 print('Total\t\t%s' % total)
78
79
80if __name__ == '__main__':

Callers 1

emsize.pyFile · 0.85

Calls 3

splitMethod · 0.80
errorFunction · 0.70
printFunction · 0.50

Tested by

no test coverage detected