Skip to content

Commit 9232379

Browse files
authored
Split up other.test_mallocs to multiple individual test_malloc_size_* tests. (#25554)
Split up other.test_mallocs to multiple individual test_malloc_size_* tests. Reduces runtime from 26.5 seconds down to 5.5 seconds on a Ryzen 5950X system.
1 parent d653a2a commit 9232379

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

test/test_other.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7954,33 +7954,20 @@ def test_dlmalloc_modes(self):
79547954
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
79557955
self.assertContained('native code called abort()', out)
79567956

7957-
@is_slow_test
7958-
def test_mallocs(self):
7959-
def run(opts):
7960-
print(opts)
7961-
sizes = {}
7962-
for malloc, name in (
7963-
('dlmalloc', 'dlmalloc'),
7964-
(None, 'default'),
7965-
('emmalloc', 'emmalloc'),
7966-
('mimalloc', 'mimalloc'),
7967-
):
7968-
print(malloc, name)
7969-
args = opts[:]
7970-
if malloc:
7971-
args += ['-sMALLOC=%s' % malloc]
7972-
print(args)
7973-
self.emcc('hello_libcxx.cpp', args=args)
7974-
sizes[name] = os.path.getsize('a.out.wasm')
7975-
print(sizes)
7976-
# dlmalloc is the default
7977-
self.assertEqual(sizes['dlmalloc'], sizes['default'])
7978-
# emmalloc is much smaller
7979-
self.assertLess(sizes['emmalloc'], sizes['dlmalloc'] - 5000)
7980-
# mimalloc is much larger
7981-
self.assertGreater(sizes['mimalloc'], sizes['dlmalloc'] - 25000)
7982-
run([])
7983-
run(['-O2'])
7957+
@parameterized({
7958+
'': ([], 190000),
7959+
'O2': (['-O2'], 132000),
7960+
'emmalloc': (['-sMALLOC=emmalloc'], 185000),
7961+
'dlmalloc': (['-sMALLOC=dlmalloc'], 190000),
7962+
'mimalloc': (['-sMALLOC=mimalloc'], 245000),
7963+
'emmalloc_O2': (['-sMALLOC=emmalloc', '-O2'], 125000),
7964+
'dlmalloc_O2': (['-sMALLOC=dlmalloc', '-O2'], 132000),
7965+
'mimalloc_O2': (['-sMALLOC=mimalloc', '-O2'], 180000),
7966+
})
7967+
# This test verifies the output code size of the different -sMALLOC= modes.
7968+
def test_malloc_size(self, args, max_size):
7969+
self.emcc('hello_libcxx.cpp', args=args)
7970+
self.assertLess(os.path.getsize('a.out.wasm'), max_size)
79847971

79857972
def test_emmalloc_2GB(self):
79867973
def test(args, text=None):

0 commit comments

Comments
 (0)