From: stephan Date: Thu, 8 Sep 2022 15:30:59 +0000 (+0000) Subject: Add speedtest1-worker.html, an interactive Worker-thread variant of speedtest1.html... X-Git-Tag: version-3.40.0~169^2~135 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=44a87f08efbb4d19bb935afb44c3472b4a54a9f9;p=thirdparty%2Fsqlite.git Add speedtest1-worker.html, an interactive Worker-thread variant of speedtest1.html. Add ext/wasm/index.html to act as a gateway to the various test pages. FossilOrigin-Name: f16c68ee6d5ebb8dec2ab656dbab2ddb5f1d5133153ad553f986b31020adaa38 --- diff --git a/ext/wasm/batch-runner.html b/ext/wasm/batch-runner.html index 10f7e45df7..38f38070c0 100644 --- a/ext/wasm/batch-runner.html +++ b/ext/wasm/batch-runner.html @@ -59,33 +59,5 @@ - diff --git a/ext/wasm/common/testing.css b/ext/wasm/common/testing.css index 09c570f48a..e112fd0a83 100644 --- a/ext/wasm/common/testing.css +++ b/ext/wasm/common/testing.css @@ -1,3 +1,8 @@ +body { + display: flex; + flex-direction: column; + flex-wrap: wrap; +} textarea { font-family: monospace; } @@ -29,4 +34,17 @@ span.labeled-input { color: red; background-color: yellow; } -#test-output { font-family: monospace } +.warning { color: firebrick; } +.input-wrapper { white-space: nowrap; } +#test-output { + border: 1px inset; + padding: 0.25em; + /*max-height: 30em;*/ + overflow: auto; + white-space: break-spaces; + display: flex; flex-direction: column; + font-family: monospace; +} +#test-output.reverse { + flex-direction: column-reverse; +} diff --git a/ext/wasm/index.html b/ext/wasm/index.html new file mode 100644 index 0000000000..def70cce03 --- /dev/null +++ b/ext/wasm/index.html @@ -0,0 +1,54 @@ + + + + + + + + sqlite3 WASM Testing Page Index + + +
sqlite3 WASM test pages
+
+
Below is the list of test pages for the sqlite3 WASM + builds. All of them require that this directory have been + "make"d first. The intent is that this page be run + using:
+
althttpd -page index.html
+
and the individual tests be started in their own tab.
+
Warnings and Caveats: + +
+
The tests... + +
+ + + + diff --git a/ext/wasm/speedtest1-worker.html b/ext/wasm/speedtest1-worker.html new file mode 100644 index 0000000000..60c475798c --- /dev/null +++ b/ext/wasm/speedtest1-worker.html @@ -0,0 +1,315 @@ + + + + + + + + + speedtest1.wasm Worker + + +
speedtest1.wasm Worker
+
See also: A main-thread variant of this page.
+ +
+
+
Initializing app...
+
+ On a slow internet connection this may take a moment. If this + message displays for "a long time", intialization may have + failed and the JavaScript console may contain clues as to why. +
+
+
Downloading...
+
+ +
+ +
+ + + + +
+
+ + + + diff --git a/ext/wasm/speedtest1-worker.js b/ext/wasm/speedtest1-worker.js new file mode 100644 index 0000000000..8512bdbbf7 --- /dev/null +++ b/ext/wasm/speedtest1-worker.js @@ -0,0 +1,99 @@ +'use strict'; +(function(){ + importScripts('common/whwasmutil.js','speedtest1.js'); + /** + If this environment contains OPFS, this function initializes it and + returns the name of the dir on which OPFS is mounted, else it returns + an empty string. + */ + const opfsDir = function f(wasmUtil){ + if(undefined !== f._) return f._; + const pdir = '/persistent'; + if( !self.FileSystemHandle + || !self.FileSystemDirectoryHandle + || !self.FileSystemFileHandle){ + return f._ = ""; + } + try{ + if(0===wasmUtil.xCallWrapped( + 'sqlite3_wasm_init_opfs', 'i32', ['string'], pdir + )){ + return f._ = pdir; + }else{ + return f._ = ""; + } + }catch(e){ + // sqlite3_wasm_init_opfs() is not available + return f._ = ""; + } + }; + opfsDir._ = undefined; + + const mPost = function(msgType,payload){ + postMessage({type: msgType, data: payload}); + }; + + const App = Object.create(null); + App.logBuffer = []; + const logMsg = (type,msgArgs)=>{ + const msg = msgArgs.join(' '); + App.logBuffer.push(msg); + mPost(type,msg); + }; + const log = (...args)=>logMsg('stdout',args); + const logErr = (...args)=>logMsg('stderr',args); + + const runSpeedtest = function(cliFlagsArray){ + const scope = App.wasm.scopedAllocPush(); + const dbFile = 0 ? "" : App.pDir+"/speedtest1.db"; + try{ + const argv = [ + "speedtest1.wasm", ...cliFlagsArray, dbFile + ]; + App.logBuffer.length = 0; + mPost('run-start', [...argv]); + App.wasm.xCall('__main_argc_argv', argv.length, + App.wasm.scopedAllocMainArgv(argv)); + }catch(e){ + mPost('error',e.message); + }finally{ + App.wasm.scopedAllocPop(scope); + App.unlink(dbFile); + mPost('run-end', App.logBuffer.join('\n')); + App.logBuffer.length = 0; + } + }; + + self.onmessage = function(msg){ + msg = msg.data; + switch(msg.type){ + case 'run': runSpeedtest(msg.data || []); break; + default: + logErr("Unhandled worker message type:",msg.type); + break; + } + }; + + const EmscriptenModule = { + print: log, + printErr: logErr, + setStatus: (text)=>mPost('load-status',text) + }; + self.sqlite3Speedtest1InitModule(EmscriptenModule).then(function(EmscriptenModule){ + log("Module inited."); + App.wasm = { + exports: EmscriptenModule.asm, + alloc: (n)=>EmscriptenModule._malloc(n), + dealloc: (m)=>EmscriptenModule._free(m), + memory: EmscriptenModule.asm.memory || EmscriptenModule.wasmMemory + }; + //console.debug('wasm =',wasm); + self.WhWasmUtilInstaller(App.wasm); + App.unlink = App.wasm.xWrap("sqlite3_wasm_vfs_unlink", "int", ["string"]); + App.pDir = opfsDir(App.wasm); + if(App.pDir){ + log("Persistent storage:",pDir); + } + mPost('ready',true); + }); +})(); diff --git a/ext/wasm/speedtest1.html b/ext/wasm/speedtest1.html index 5e05feed26..fad2b28129 100644 --- a/ext/wasm/speedtest1.html +++ b/ext/wasm/speedtest1.html @@ -10,6 +10,7 @@
speedtest1.wasm
+
See also: A Worker-thread variant of this page.
@@ -24,6 +25,9 @@
+
This page starts running the main exe when it loads, which will + block the UI until it finishes! Adding UI controls to manually configure and start it + are TODO.
Output is sent to the dev console because we cannot update the UI while the speedtest is running unless/until we move the speedtest to a worker thread.

diff --git a/manifest b/manifest index aef6da12d0..75eb7e14a6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snote\sabout\sEmscripten's\s-sSINGLE_FILE\sflag,\swhy\sit\swould\sbe\snice,\sand\swhy\swe\scan't\suse\sit. -D 2022-09-06T23:04:51.823 +C Add\sspeedtest1-worker.html,\san\sinteractive\sWorker-thread\svariant\sof\sspeedtest1.html.\sAdd\sext/wasm/index.html\sto\sact\sas\sa\sgateway\sto\sthe\svarious\stest\spages. +D 2022-09-08T15:30:59.731 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -489,11 +489,11 @@ F ext/wasm/api/sqlite3-api-prologue.js 2d5c5d3355f55eefe51922cec5bfedbec0f8300db F ext/wasm/api/sqlite3-api-worker1.js 73579555563b789785ae83724014eaf31811073aad9be6596c8336ffb51edd71 F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9 F ext/wasm/api/sqlite3-wasm.c 19c3797edc35821e362a8b60ce45d1adfe6d24fca7cd1f55f89d2086ef33870e -F ext/wasm/batch-runner.html 2d44d99a556c46f586d3319003dd281dd0eb6a13eeadde3eab05ba81eec9ff8a +F ext/wasm/batch-runner.html 23209ade7981acce7ecd79d6eff9f4c5a4e8b14ae867ac27cd89b230be640fa6 F ext/wasm/batch-runner.js a727cbbffe63fd17fb5a590dc679f0b13bd51880e8f84b461d7df246417689e8 F ext/wasm/common/SqliteTestUtil.js 7a543e238c2ebda922c85076abda017d0480944fdfee576692a0c3a580319ebd F ext/wasm/common/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f -F ext/wasm/common/testing.css 572cf1ffae0b6eb7ca63684d3392bf350217a07b90e7a896e4fa850700c989b0 +F ext/wasm/common/testing.css 3a5143699c2b73a85b962271e1a9b3241b30d90e30d895e4f55665e648572962 F ext/wasm/common/whwasmutil.js f7282ef36c9625330d4e6e82d1beec6678cd101e95e7108cd85db587a788c145 F ext/wasm/demo-oo1.html 75646855b38405d82781246fd08c852a2b3bee05dd9f0fe10ab655a8cffb79aa F ext/wasm/demo-oo1.js aad38cb90b6fa7fd4d1184e759b25056fb4ed45c4957c458896354281259515f @@ -501,6 +501,7 @@ F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d695 F ext/wasm/fiddle/fiddle-worker.js bccf46045be8824752876f3eec01c223be0616ccac184bffd0024cfe7a3262b8 F ext/wasm/fiddle/fiddle.html 550c5aafce40bd218de9bf26192749f69f9b10bc379423ecd2e162bcef885c08 F ext/wasm/fiddle/fiddle.js 4ffcfc9a235beebaddec689a549e9e0dfad6dca5c1f0b41f03468d7e76480686 +F ext/wasm/index.html 4f635f986dbc7518280abe0ef537ba41682e35f160fac35a0745cf6c4d223b62 F ext/wasm/jaccwabyt/jaccwabyt.js 0d7f32817456a0f3937fcfd934afeb32154ca33580ab264dab6c285e6dbbd215 F ext/wasm/jaccwabyt/jaccwabyt.md 447cc02b598f7792edaa8ae6853a7847b8178a18ed356afacbdbf312b2588106 F ext/wasm/jaccwabyt/jaccwabyt_test.c 39e4b865a33548f943e2eb9dd0dc8d619a80de05d5300668e9960fff30d0d36f @@ -510,7 +511,9 @@ F ext/wasm/scratchpad-opfs-main.js 69e960e9161f6412fd0c30f355d4112f1894d6609eb43 F ext/wasm/scratchpad-opfs-worker.html 66c1d15d678f3bd306373d76b61c6c8aef988f61f4a8dd40185d452f9c6d2bf5 F ext/wasm/scratchpad-opfs-worker.js 3ec2868c669713145c76eb5877c64a1b20741f741817b87c907a154b676283a9 F ext/wasm/scratchpad-opfs-worker2.js 5f2237427ac537b8580b1c659ff14ad2621d1694043eaaf41ae18dbfef2e48c0 -F ext/wasm/speedtest1.html a1204f5cbbd592baa191535dc7eaa2d875f661aefb2a70a4631df0a925e19f4b +F ext/wasm/speedtest1-worker.html 4f8d7391ec17b6fd13f1a1e181436d3331842548fe7cc84e4e322f72850eb97b +F ext/wasm/speedtest1-worker.js 356b9953add4449acf199793db9b76b11ee016021918d8daffd19f08ec68d305 +F ext/wasm/speedtest1.html 02d281c25a8048cce24695bed01ca613d11f40b599cd47f3a18dca8c982d0a15 F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0 F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5 @@ -1496,7 +1499,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest1.c 995c78f884e2388106b2b42de9e5a527e7cac01384b8f317ca0cc7b0814c9a18 +F test/speedtest1.c 55ef13e008cbb7dbea032478e60686599679b0b6192e44845c100fdabd14f8ff F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2016,8 +2019,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 40e60f570d4f489d58d12e27c1c067b41d6c5a5e374c5fce0baa8881ef183216 -R 0096ecafc15630b25658c12eafbbea1b +P 5ea0623630d769a8f3f07a40cd119be86b631192cdb5178131876b01b40ee5e0 +R b5dc0101db445e11af3bccae9adaef48 U stephan -Z 7b5e51ab80c88507303a95f3b8f5d0e1 +Z 2c78924308cfac29c905a5ead30d4718 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 08a78c3d74..9c75a6fdf6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5ea0623630d769a8f3f07a40cd119be86b631192cdb5178131876b01b40ee5e0 \ No newline at end of file +f16c68ee6d5ebb8dec2ab656dbab2ddb5f1d5133153ad553f986b31020adaa38 \ No newline at end of file diff --git a/test/speedtest1.c b/test/speedtest1.c index 401217f105..3b8bd92e3b 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -2204,6 +2204,12 @@ int main(int argc, char **argv){ int i; /* Loop counter */ int rc; /* API return code */ +#ifdef SQLITE_SPEEDTEST1_WASM + /* Resetting all state is important for the WASM build, which may + ** call main() multiple times. */ + memset(&g, 0, sizeof(g)); + iTestNumber = 0; +#endif #ifdef SQLITE_CKSUMVFS_STATIC sqlite3_register_cksumvfs(0); #endif