--- /dev/null
+<!doctype html>
+<html lang="en-us">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
+ <link rel="stylesheet" href="common/emscripten.css"/>
+ <link rel="stylesheet" href="common/testing.css"/>
+ <title>speedtest1.wasm Worker</title>
+ </head>
+ <body>
+ <header id='titlebar'>speedtest1.wasm Worker</header>
+ <div>See also: <a href='speedtest1.html'>A main-thread variant of this page.</a></div>
+ <!-- emscripten bits -->
+ <figure id="module-spinner">
+ <div class="spinner"></div>
+ <div class='center'><strong>Initializing app...</strong></div>
+ <div class='center'>
+ 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.
+ </div>
+ </figure>
+ <div class="emscripten" id="module-status">Downloading...</div>
+ <div class="emscripten">
+ <progress value="0" max="100" id="module-progress" hidden='1'></progress>
+ </div><!-- /emscripten bits -->
+ <fieldset id='ui-controls' class='hidden'>
+ <legend>Options</legend>
+ <div id='toolbar'>
+ <div id='toolbar-select'>
+ <select id='select-flags' size='10' multiple></select>
+ <div>TODO? Options which require values are not represented here.</div>
+ </div>
+ <div class='toolbar-inner-vertical' id='toolbar-selected-flags'>
+ <button id='btn-reset-flags'>Reset Flags</button>
+ <button id='btn-output-clear'>Clear output</button>
+ <button id='btn-run'>Run</button>
+ </div>
+ <div class='toolbar-inner-vertical' id='toolbar-runner-controls'>
+ <button id='btn-reset-flags'>Reset Flags</button>
+ <button id='btn-output-clear'>Clear output</button>
+ <button id='btn-run'>Run</button>
+ </div>
+ </div>
+ </fieldset>
+ <div>
+ <span class='input-wrapper'>
+ <input type='checkbox' class='disable-during-eval' id='cb-reverse-log-order' checked></input>
+ <label for='cb-reverse-log-order' id='lbl-reverse-log-order'>Reverse log order</label>
+ </span>
+ </div>
+ <div id='test-output'></div>
+ <style>
+ #test-output {
+ white-space: break-spaces;
+ overflow: auto;
+ }
+ #toolbar {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ }
+ #toolbar > * {
+ margin: 0 0.5em;
+ }
+ .toolbar-inner-vertical {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ }
+ #toolbar-select {
+ display: flex;
+ flex-direction: column;
+ }
+ .toolbar-inner-vertical > *, #toolbar-select > * {
+ margin: 0.2em 0;
+ }
+ #select-flags > option {
+ white-space: pre;
+ font-family: monospace;
+ }
+ fieldset {
+ border-radius: 0.5em;
+ }
+ #toolbar-runner-controls { flex-grow: 1 }
+ #toolbar-runner-controls > * { flex: 1 0 auto }
+ #toolbar-selected-flags::before {
+ font-family: initial;
+ content:"Selected flags: ";
+ }
+ #toolbar-selected-flags {
+ font-family: monospace;
+ justify-content: flex-start;
+ }
+ </style>
+ <script>(function(){
+ 'use strict';
+ const E = (sel)=>document.querySelector(sel);
+ const eOut = E('#test-output');
+ const log2 = function(cssClass,...args){
+ let ln;
+ if(1 || cssClass){
+ ln = document.createElement('div');
+ if(cssClass) ln.classList.add(cssClass);
+ ln.append(document.createTextNode(args.join(' ')));
+ }else{
+ // This doesn't work with the "reverse order" option!
+ ln = document.createTextNode(args.join(' ')+'\n');
+ }
+ eOut.append(ln);
+ };
+ const log = (...args)=>{
+ //console.log(...args);
+ log2('', ...args);
+ };
+ const logErr = function(...args){
+ //console.error(...args);
+ log2('error', ...args);
+ };
+ const logWarn = function(...args){
+ //console.warn(...args);
+ log2('warning', ...args);
+ };
+
+ const spacePad = function(str,len=18){
+ if(str.length===len) return str;
+ else if(str.length>len) return str.substr(0,len);
+ const a = []; a.length = len - str.length;
+ return str+a.join(' ');
+ };
+ // OPTION elements seem to ignore white-space:pre, so do this the hard way...
+ const nbspPad = function(str,len=18){
+ if(str.length===len) return str;
+ else if(str.length>len) return str.substr(0,len);
+ const a = []; a.length = len - str.length;
+ return str+a.join(' ');
+ };
+
+ const W = new Worker("speedtest1-worker.js");
+ const mPost = function(msgType,payload){
+ W.postMessage({type: msgType, data: payload});
+ };
+
+ const eFlags = E('#select-flags');
+ const eSelectedFlags = E('#toolbar-selected-flags');
+
+ const getSelectedFlags = ()=>Array.prototype.map.call(eFlags.selectedOptions, (v)=>v.value);
+ const updateSelectedFlags = function(){
+ eSelectedFlags.innerText = '';
+ getSelectedFlags().forEach(function(f){
+ const e = document.createElement('span');
+ e.innerText = f;
+ eSelectedFlags.appendChild(e);
+ });
+ };
+ eFlags.addEventListener('change', updateSelectedFlags );
+ {
+ const flags = Object.create(null);
+ /* TODO? Flags which require values need custom UI
+ controls and some of them make little sense here
+ (e.g. --script FILE). */
+ flags["autovacuum"] = "Enable AUTOVACUUM mode";
+ //flags["cachesize"] = "N Set the cache size to N";
+ flags["checkpoint"] = "Run PRAGMA wal_checkpoint after each test case";
+ flags["exclusive"] = "Enable locking_mode=EXCLUSIVE";
+ flags["explain"] = "Like --sqlonly but with added EXPLAIN keywords";
+ //flags["heap"] = "SZ MIN Memory allocator uses SZ bytes & min allocation MIN";
+ flags["incrvacuum"] = "Enable incremenatal vacuum mode";
+ //flags["journal"] = "M Set the journal_mode to M";
+ //flags["key"] = "KEY Set the encryption key to KEY";
+ //flags["lookaside"] = "N SZ Configure lookaside for N slots of SZ bytes each";
+ flags["memdb"] = "Use an in-memory database";
+ //flags["mmap"] = "SZ MMAP the first SZ bytes of the database file";
+ flags["multithread"] = "Set multithreaded mode";
+ flags["nomemstat"] = "Disable memory statistics";
+ flags["nosync"] = "Set PRAGMA synchronous=OFF";
+ flags["notnull"] = "Add NOT NULL constraints to table columns";
+ //flags["output"] = "FILE Store SQL output in FILE";
+ //flags["pagesize"] = "N Set the page size to N";
+ //flags["pcache"] = "N SZ Configure N pages of pagecache each of size SZ bytes";
+ //flags["primarykey"] = "Use PRIMARY KEY instead of UNIQUE where appropriate";
+ //flags["repeat"] = "N Repeat each SELECT N times (default: 1)";
+ flags["reprepare"] = "Reprepare each statement upon every invocation";
+ //flags["reserve"] = "N Reserve N bytes on each database page";
+ //flags["script"] = "FILE Write an SQL script for the test into FILE";
+ flags["serialized"] = "Set serialized threading mode";
+ flags["singlethread"] = "Set single-threaded mode - disables all mutexing";
+ flags["sqlonly"] = "No-op. Only show the SQL that would have been run.";
+ flags["shrink"] = "memory Invoke sqlite3_db_release_memory() frequently.";
+ //flags["size"] = "N Relative test size. Default=100";
+ flags["strict"] = "Use STRICT table where appropriate";
+ flags["stats"] = "Show statistics at the end";
+ //flags["temp"] = "N N from 0 to 9. 0: no temp table. 9: all temp tables";
+ //flags["testset"] = "T Run test-set T (main, cte, rtree, orm, fp, debug)";
+ flags["trace"] = "Turn on SQL tracing";
+ //flags["threads"] = "N Use up to N threads for sorting";
+ /*
+ The core API's WASM build does not support UTF16, but in
+ this app it's not an issue because the data are not crossing
+ JS/WASM boundaries.
+ */
+ flags["utf16be"] = "Set text encoding to UTF-16BE";
+ flags["utf16le"] = "Set text encoding to UTF-16LE";
+ flags["verify"] = "Run additional verification steps.";
+ flags["without"] = "rowid Use WITHOUT ROWID where appropriate";
+ const preselectedFlags = [
+ 'singlethread',
+ 'memdb'
+ ];
+ Object.keys(flags).sort().forEach(function(f){
+ const opt = document.createElement('option');
+ eFlags.appendChild(opt);
+ const lbl = nbspPad('--'+f)+flags[f];
+ //opt.innerText = lbl;
+ opt.innerHTML = lbl;
+ opt.value = '--'+f;
+ if(preselectedFlags.indexOf(f) >= 0) opt.selected = true;
+ });
+
+ const cbReverseLog = E('#cb-reverse-log-order');
+ const lblReverseLog = E('#lbl-reverse-log-order');
+ if(cbReverseLog.checked){
+ lblReverseLog.classList.add('warning');
+ eOut.classList.add('reverse');
+ }
+ cbReverseLog.addEventListener('change', function(){
+ if(this.checked){
+ eOut.classList.add('reverse');
+ lblReverseLog.classList.add('warning');
+ }else{
+ eOut.classList.remove('reverse');
+ lblReverseLog.classList.remove('warning');
+ }
+ }, false);
+ updateSelectedFlags();
+ }
+ E('#btn-output-clear').addEventListener('click', ()=>{
+ eOut.innerText = '';
+ });
+ E('#btn-reset-flags').addEventListener('click',()=>{
+ eFlags.value = '';
+ updateSelectedFlags();
+ });
+ E('#btn-run').addEventListener('click',function(){
+ log("Running speedtest1. UI controls will be disabled until it completes.");
+ mPost('run', getSelectedFlags());
+ });
+
+ const eControls = E('#ui-controls');
+ /** Update Emscripten-related UI elements while loading the module. */
+ const updateLoadStatus = function f(text){
+ if(!f.last){
+ f.last = { text: '', step: 0 };
+ const E = (cssSelector)=>document.querySelector(cssSelector);
+ f.ui = {
+ status: E('#module-status'),
+ progress: E('#module-progress'),
+ spinner: E('#module-spinner')
+ };
+ }
+ if(text === f.last.text) return;
+ f.last.text = text;
+ if(f.ui.progress){
+ f.ui.progress.value = f.last.step;
+ f.ui.progress.max = f.last.step + 1;
+ }
+ ++f.last.step;
+ if(text) {
+ f.ui.status.classList.remove('hidden');
+ f.ui.status.innerText = text;
+ }else{
+ if(f.ui.progress){
+ f.ui.progress.remove();
+ f.ui.spinner.remove();
+ delete f.ui.progress;
+ delete f.ui.spinner;
+ }
+ f.ui.status.classList.add('hidden');
+ }
+ };
+
+ log("Control-click the flags to (de)select multiple flags.");
+ logWarn("\nThe easiest way to try different optimization levels is, from this directory:\n"+
+ " $ make clean; make -e emcc_opt='-O2' speedtest1\n"+
+ "Then reload this page. -O2 seems to consistently produce the fastest results.\n");
+ logWarn('\nAchtung: the Worker thread overhead slightly reduces the speed',
+ 'compared to running the same options via speedtest1.html.\n'+
+ 'TODO: add a link in this app which launches the main-thread',
+ 'version with the same flags.\n');
+
+ W.onmessage = function(msg){
+ msg = msg.data;
+ switch(msg.type){
+ case 'ready': log("Worker is ready."); eControls.classList.remove('hidden'); break;
+ case 'stdout': log(msg.data); break;
+ case 'stdout': logErr(msg.data); break;
+ case 'run-start':
+ eControls.disabled = true;
+ log("Running speedtest1 with argv =",msg.data.join(' '));
+ break;
+ case 'run-end': log("speedtest1 finished.");
+ eControls.disabled = false;
+ // app output is in msg.data
+ break;
+ case 'error': logErr(msg.data); break;
+ case 'load-status': updateLoadStatus(msg.data); break;
+ default:
+ logErr("Unhandled worker message type:",arguments[0]);
+ break;
+ }
+ };
+ })();</script>
+ </body>
+</html>
--- /dev/null
+'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);
+ });
+})();
-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
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
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
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
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
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.