diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-06-05 02:00:08 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-06-05 05:54:04 +0300 |
commit | 92cab32f5ffcc00779b521588bec62f597c98aa7 (patch) | |
tree | a7c248ecf7a34dac50f326e62f8c398ec07ab2c6 /tests/test_core.py | |
parent | 3431eab292e0b9e2359b183fa2c954eb7e5cf7e7 (diff) |
Use typed arrays instead of normal JS arrays to back files in the MEMFS filesystem for improved performance, especially when backing to IDBFS.
Diffstat (limited to 'tests/test_core.py')
-rw-r--r-- | tests/test_core.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index bcb03830..f34ba03e 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -4030,11 +4030,14 @@ def process(filename): src = open(path_from_root('tests', 'files.cpp'), 'r').read() mem_file = 'src.cpp.o.js.mem' - try_delete(mem_file) - self.do_run(src, ('size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\ntexte\n', 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\n'), - post_build=post, extra_emscripten_args=['-H', 'libc/fcntl.h']) - if self.emcc_args and '--memory-init-file' in self.emcc_args: - assert os.path.exists(mem_file) + orig_args = self.emcc_args + for modes in [[], ['-s', 'MEMFS_APPEND_TO_TYPED_ARRAYS=1']]: + self.emcc_args = orig_args + modes + try_delete(mem_file) + self.do_run(src, ('size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\ntexte\n', 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\n'), + post_build=post, extra_emscripten_args=['-H', 'libc/fcntl.h']) + if self.emcc_args and '--memory-init-file' in self.emcc_args: + assert os.path.exists(mem_file) def test_files_m(self): # Test for Module.stdin etc. @@ -4275,7 +4278,10 @@ def process(filename): if self.emcc_args is None: return self.skip('requires libcxx') test_path = path_from_root('tests', 'core', 'test_wprintf') src, output = (test_path + s for s in ('.c', '.out')) - self.do_run_from_file(src, output) + orig_args = self.emcc_args + for modes in [[], ['-s', 'MEMFS_APPEND_TO_TYPED_ARRAYS=1']]: + self.emcc_args = orig_args + modes + self.do_run_from_file(src, output) def test_direct_string_constant_usage(self): if self.emcc_args is None: return self.skip('requires libcxx') @@ -5108,7 +5114,7 @@ def process(filename): \'\'\' FS.createDataFile('/', 'paper.pdf', eval(Module.read('paper.pdf.js')), true, false); Module.callMain(Module.arguments); - Module.print("Data: " + JSON.stringify(FS.root.contents['filename-1.ppm'].contents.map(function(x) { return unSign(x, 8) }))); + Module.print("Data: " + JSON.stringify(MEMFS.getFileDataAsRegularArray(FS.root.contents['filename-1.ppm']).map(function(x) { return unSign(x, 8) }))); \'\'\' ) src.close() @@ -5158,7 +5164,7 @@ def process(filename): )) ).replace( '// {{POST_RUN_ADDITIONS}}', - "Module.print('Data: ' + JSON.stringify(FS.analyzePath('image.raw').object.contents));" + "Module.print('Data: ' + JSON.stringify(MEMFS.getFileDataAsRegularArray(FS.analyzePath('image.raw').object)));" ) open(filename, 'w').write(src) ''' |