mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
speedtest1 wasm: add a link in the worker variant which launches the main-thread variant with the selected CLI flags. Append collected stdout/stderr to the main-thread page after execution is finished to avoid having to open the dev tools (which inexplicably slows down wasm execution).
FossilOrigin-Name: 02709ee2beab36d144b807fd9ffaee639e3c1bdd1908a34e05f3fd23dad2ef66
This commit is contained in:
@@ -113,6 +113,46 @@
|
|||||||
++this.counter;
|
++this.counter;
|
||||||
if(!this.toBool(expr)) throw new Error(msg || "throwUnless() failed");
|
if(!this.toBool(expr)) throw new Error(msg || "throwUnless() failed");
|
||||||
return this;
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Parses window.location.search-style string into an object
|
||||||
|
containing key/value pairs of URL arguments (already
|
||||||
|
urldecoded). The object is created using Object.create(null),
|
||||||
|
so contains only parsed-out properties and has no prototype
|
||||||
|
(and thus no inherited properties).
|
||||||
|
|
||||||
|
If the str argument is not passed (arguments.length==0) then
|
||||||
|
window.location.search.substring(1) is used by default. If
|
||||||
|
neither str is passed in nor window exists then false is returned.
|
||||||
|
|
||||||
|
On success it returns an Object containing the key/value pairs
|
||||||
|
parsed from the string. Keys which have no value are treated
|
||||||
|
has having the boolean true value.
|
||||||
|
|
||||||
|
Pedantic licensing note: this code has appeared in other source
|
||||||
|
trees, but was originally written by the same person who pasted
|
||||||
|
it into those trees.
|
||||||
|
*/
|
||||||
|
processUrlArgs: function(str) {
|
||||||
|
if( 0 === arguments.length ) {
|
||||||
|
if( ('undefined' === typeof window) ||
|
||||||
|
!window.location ||
|
||||||
|
!window.location.search ) return false;
|
||||||
|
else str = (''+window.location.search).substring(1);
|
||||||
|
}
|
||||||
|
if( ! str ) return false;
|
||||||
|
str = (''+str).split(/#/,2)[0]; // remove #... to avoid it being added as part of the last value.
|
||||||
|
const args = Object.create(null);
|
||||||
|
const sp = str.split(/&+/);
|
||||||
|
const rx = /^([^=]+)(=(.+))?/;
|
||||||
|
var i, m;
|
||||||
|
for( i in sp ) {
|
||||||
|
m = rx.exec( sp[i] );
|
||||||
|
if( ! m ) continue;
|
||||||
|
args[decodeURIComponent(m[1])] = (m[3] ? decodeURIComponent(m[3]) : true);
|
||||||
|
}
|
||||||
|
return args;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -32,10 +32,11 @@
|
|||||||
<select id='select-flags' size='10' multiple></select>
|
<select id='select-flags' size='10' multiple></select>
|
||||||
<div>TODO? Options which require values are not represented here.</div>
|
<div>TODO? Options which require values are not represented here.</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='toolbar-inner-vertical' id='toolbar-selected-flags'>
|
<div class='toolbar-inner-vertical'>
|
||||||
<button id='btn-reset-flags'>Reset Flags</button>
|
<div id='toolbar-selected-flags'></div>
|
||||||
<button id='btn-output-clear'>Clear output</button>
|
<span>→ <a id='link-main-thread' href='#' target='main-thread'
|
||||||
<button id='btn-run'>Run</button>
|
title='Start speedtest1.html with the selected flags'>speedtest1.html</a>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='toolbar-inner-vertical' id='toolbar-runner-controls'>
|
<div class='toolbar-inner-vertical' id='toolbar-runner-controls'>
|
||||||
<button id='btn-reset-flags'>Reset Flags</button>
|
<button id='btn-reset-flags'>Reset Flags</button>
|
||||||
@@ -105,6 +106,8 @@
|
|||||||
content:"Selected flags: ";
|
content:"Selected flags: ";
|
||||||
}
|
}
|
||||||
#toolbar-selected-flags {
|
#toolbar-selected-flags {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
@@ -138,14 +141,14 @@
|
|||||||
log2('warning', ...args);
|
log2('warning', ...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
const spacePad = function(str,len=18){
|
const spacePad = function(str,len=21){
|
||||||
if(str.length===len) return str;
|
if(str.length===len) return str;
|
||||||
else if(str.length>len) return str.substr(0,len);
|
else if(str.length>len) return str.substr(0,len);
|
||||||
const a = []; a.length = len - str.length;
|
const a = []; a.length = len - str.length;
|
||||||
return str+a.join(' ');
|
return str+a.join(' ');
|
||||||
};
|
};
|
||||||
// OPTION elements seem to ignore white-space:pre, so do this the hard way...
|
// OPTION elements seem to ignore white-space:pre, so do this the hard way...
|
||||||
const nbspPad = function(str,len=18){
|
const nbspPad = function(str,len=21){
|
||||||
if(str.length===len) return str;
|
if(str.length===len) return str;
|
||||||
else if(str.length>len) return str.substr(0,len);
|
else if(str.length>len) return str.substr(0,len);
|
||||||
const a = []; a.length = len - str.length;
|
const a = []; a.length = len - str.length;
|
||||||
@@ -159,15 +162,20 @@
|
|||||||
|
|
||||||
const eFlags = E('#select-flags');
|
const eFlags = E('#select-flags');
|
||||||
const eSelectedFlags = E('#toolbar-selected-flags');
|
const eSelectedFlags = E('#toolbar-selected-flags');
|
||||||
|
const eLinkMainThread = E('#link-main-thread');
|
||||||
const getSelectedFlags = ()=>Array.prototype.map.call(eFlags.selectedOptions, (v)=>v.value);
|
const getSelectedFlags = ()=>Array.prototype.map.call(eFlags.selectedOptions, (v)=>v.value);
|
||||||
const updateSelectedFlags = function(){
|
const updateSelectedFlags = function(){
|
||||||
eSelectedFlags.innerText = '';
|
eSelectedFlags.innerText = '';
|
||||||
getSelectedFlags().forEach(function(f){
|
const flags = getSelectedFlags();
|
||||||
|
flags.forEach(function(f){
|
||||||
const e = document.createElement('span');
|
const e = document.createElement('span');
|
||||||
e.innerText = f;
|
e.innerText = f;
|
||||||
eSelectedFlags.appendChild(e);
|
eSelectedFlags.appendChild(e);
|
||||||
});
|
});
|
||||||
|
const rxStripDash = /^(-+)?/;
|
||||||
|
const comma = flags.map((v)=>v.replace(rxStripDash,'')).join(',');
|
||||||
|
eLinkMainThread.setAttribute('target', 'main-thread-'+comma);
|
||||||
|
eLinkMainThread.href = 'speedtest1.html?flags='+comma;
|
||||||
};
|
};
|
||||||
eFlags.addEventListener('change', updateSelectedFlags );
|
eFlags.addEventListener('change', updateSelectedFlags );
|
||||||
{
|
{
|
||||||
|
@@ -28,16 +28,14 @@
|
|||||||
<div class='warning'>This page starts running the main exe when it loads, which will
|
<div class='warning'>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
|
block the UI until it finishes! Adding UI controls to manually configure and start it
|
||||||
are TODO.</div>
|
are TODO.</div>
|
||||||
<div>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.
|
|
||||||
</div>
|
</div>
|
||||||
<div class='warning'>Achtung: running it with the dev tools open <em>drastically</em>
|
<div class='warning'>Achtung: running it with the dev tools open may
|
||||||
slows it down: by a factor of 2.5+. For faster results, keep the dev tools closed
|
<em>drastically</em> slow it down. For faster results, keep the dev
|
||||||
when running it!
|
tools closed when running it!
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<div id='test-output'>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div>Output is delayed/buffered because we cannot update the UI while the
|
||||||
|
speedtest is running. Output will appear below when ready...
|
||||||
|
<div id='test-output'></div>
|
||||||
<script src="common/whwasmutil.js"></script>
|
<script src="common/whwasmutil.js"></script>
|
||||||
<script src="common/SqliteTestUtil.js"></script>
|
<script src="common/SqliteTestUtil.js"></script>
|
||||||
<script src="speedtest1.js"></script>
|
<script src="speedtest1.js"></script>
|
||||||
@@ -78,16 +76,20 @@
|
|||||||
eOut.append(ln);
|
eOut.append(ln);
|
||||||
//this.e.output.lastElementChild.scrollIntoViewIfNeeded();
|
//this.e.output.lastElementChild.scrollIntoViewIfNeeded();
|
||||||
};
|
};
|
||||||
const doHtmlOutput = false
|
const logList = [];
|
||||||
|
const dumpLogList = function(){
|
||||||
|
logList.forEach((v)=>log2('',v));
|
||||||
|
logList.length = 0;
|
||||||
|
};
|
||||||
/* can't update DOM while speedtest is running unless we run
|
/* can't update DOM while speedtest is running unless we run
|
||||||
speedtest in a worker thread. */;
|
speedtest in a worker thread. */;
|
||||||
const log = (...args)=>{
|
const log = (...args)=>{
|
||||||
console.log(...args);
|
console.log(...args);
|
||||||
if(doHtmlOutput) log2('', ...args);
|
logList.push(args.join(' '));
|
||||||
};
|
};
|
||||||
const logErr = function(...args){
|
const logErr = function(...args){
|
||||||
console.error(...args);
|
console.error(...args);
|
||||||
if(doHtmlOutput) log2('error', ...args);
|
logList.push('ERROR: '+args.join(' '));
|
||||||
};
|
};
|
||||||
|
|
||||||
const runTests = function(EmscriptenModule){
|
const runTests = function(EmscriptenModule){
|
||||||
@@ -107,31 +109,38 @@
|
|||||||
}
|
}
|
||||||
const scope = wasm.scopedAllocPush();
|
const scope = wasm.scopedAllocPush();
|
||||||
const dbFile = 0 ? "" : pDir+"/speedtest1.db";
|
const dbFile = 0 ? "" : pDir+"/speedtest1.db";
|
||||||
const argv = [
|
const urlArgs = self.SqliteTestUtil.processUrlArgs();
|
||||||
// TODO: accept flags via URL arguments and/or a
|
const argv = ["speedtest1"];
|
||||||
// UI control. A multi-SELECT element should do
|
if(urlArgs.flags){
|
||||||
// nicely.
|
// transform flags=a,b,c to ["--a", "--b", "--c"]
|
||||||
"speedtest1",
|
argv.push(...(urlArgs.flags.split(',').map((v)=>'--'+v)));
|
||||||
"--singlethread",
|
}else{
|
||||||
"--nomutex",
|
argv.push(
|
||||||
"--nosync",
|
"--singlethread",
|
||||||
"--nomemstat",
|
"--nomutex",
|
||||||
"--big-transactions", // important for tests 410 and 510!
|
"--nosync",
|
||||||
|
"--nomemstat"
|
||||||
|
);
|
||||||
//"--memdb", // note that memdb trumps the filename arg
|
//"--memdb", // note that memdb trumps the filename arg
|
||||||
dbFile
|
argv.push("--big-transactions"/*important for tests 410 and 510!*/,
|
||||||
];
|
dbFile);
|
||||||
|
}
|
||||||
console.log("argv =",argv);
|
console.log("argv =",argv);
|
||||||
// These log messages are not emitted to the UI until after main() returns. Fixing that
|
// These log messages are not emitted to the UI until after main() returns. Fixing that
|
||||||
// requires moving the main() call and related cleanup into a timeout handler.
|
// requires moving the main() call and related cleanup into a timeout handler.
|
||||||
log2('',"Starting native main() with flags:",argv.join(' '));
|
if(pDir) unlink(dbFile);
|
||||||
log2('',"This will take a while and the browser might warn about the runaway JS. Give it time.");
|
log2('',"Starting native app:\n ",argv.join(' '));
|
||||||
|
log2('',"This will take a while and the browser might warn about the runaway JS.",
|
||||||
|
"Give it time...");
|
||||||
|
logList.length = 0;
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
wasm.xCall('__main_argc_argv', argv.length,
|
wasm.xCall('__main_argc_argv', argv.length,
|
||||||
wasm.scopedAllocMainArgv(argv));
|
wasm.scopedAllocMainArgv(argv));
|
||||||
wasm.scopedAllocPop(scope);
|
wasm.scopedAllocPop(scope);
|
||||||
if(pDir) unlink(dbFile);
|
if(pDir) unlink(dbFile);
|
||||||
log2('',"Done running native main(). Check dev console for output.");
|
logList.unshift("Done running native main(). Output:");
|
||||||
}, 100);
|
dumpLogList();
|
||||||
|
}, 50);
|
||||||
}/*runTests()*/;
|
}/*runTests()*/;
|
||||||
|
|
||||||
self.sqlite3TestModule.print = log;
|
self.sqlite3TestModule.print = log;
|
||||||
|
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Make\suse\sof\sthe\s--big-transactions\sflag\sin\sthe\sspeedtest1\sJS\sapps.
|
C speedtest1\swasm:\sadd\sa\slink\sin\sthe\sworker\svariant\swhich\slaunches\sthe\smain-thread\svariant\swith\sthe\sselected\sCLI\sflags.\sAppend\scollected\sstdout/stderr\sto\sthe\smain-thread\spage\safter\sexecution\sis\sfinished\sto\savoid\shaving\sto\sopen\sthe\sdev\stools\s(which\sinexplicably\sslows\sdown\swasm\sexecution).
|
||||||
D 2022-09-08T21:33:50.335
|
D 2022-09-09T04:50:18.498
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -491,7 +491,7 @@ F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b56
|
|||||||
F ext/wasm/api/sqlite3-wasm.c 19c3797edc35821e362a8b60ce45d1adfe6d24fca7cd1f55f89d2086ef33870e
|
F ext/wasm/api/sqlite3-wasm.c 19c3797edc35821e362a8b60ce45d1adfe6d24fca7cd1f55f89d2086ef33870e
|
||||||
F ext/wasm/batch-runner.html 23209ade7981acce7ecd79d6eff9f4c5a4e8b14ae867ac27cd89b230be640fa6
|
F ext/wasm/batch-runner.html 23209ade7981acce7ecd79d6eff9f4c5a4e8b14ae867ac27cd89b230be640fa6
|
||||||
F ext/wasm/batch-runner.js a727cbbffe63fd17fb5a590dc679f0b13bd51880e8f84b461d7df246417689e8
|
F ext/wasm/batch-runner.js a727cbbffe63fd17fb5a590dc679f0b13bd51880e8f84b461d7df246417689e8
|
||||||
F ext/wasm/common/SqliteTestUtil.js 7a543e238c2ebda922c85076abda017d0480944fdfee576692a0c3a580319ebd
|
F ext/wasm/common/SqliteTestUtil.js 529161a624265ba84271a52db58da022649832fa1c71309fb1e02cc037327a2b
|
||||||
F ext/wasm/common/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
|
F ext/wasm/common/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
|
||||||
F ext/wasm/common/testing.css 3a5143699c2b73a85b962271e1a9b3241b30d90e30d895e4f55665e648572962
|
F ext/wasm/common/testing.css 3a5143699c2b73a85b962271e1a9b3241b30d90e30d895e4f55665e648572962
|
||||||
F ext/wasm/common/whwasmutil.js f7282ef36c9625330d4e6e82d1beec6678cd101e95e7108cd85db587a788c145
|
F ext/wasm/common/whwasmutil.js f7282ef36c9625330d4e6e82d1beec6678cd101e95e7108cd85db587a788c145
|
||||||
@@ -511,9 +511,9 @@ F ext/wasm/scratchpad-opfs-main.js 69e960e9161f6412fd0c30f355d4112f1894d6609eb43
|
|||||||
F ext/wasm/scratchpad-opfs-worker.html 66c1d15d678f3bd306373d76b61c6c8aef988f61f4a8dd40185d452f9c6d2bf5
|
F ext/wasm/scratchpad-opfs-worker.html 66c1d15d678f3bd306373d76b61c6c8aef988f61f4a8dd40185d452f9c6d2bf5
|
||||||
F ext/wasm/scratchpad-opfs-worker.js 3ec2868c669713145c76eb5877c64a1b20741f741817b87c907a154b676283a9
|
F ext/wasm/scratchpad-opfs-worker.js 3ec2868c669713145c76eb5877c64a1b20741f741817b87c907a154b676283a9
|
||||||
F ext/wasm/scratchpad-opfs-worker2.js 5f2237427ac537b8580b1c659ff14ad2621d1694043eaaf41ae18dbfef2e48c0
|
F ext/wasm/scratchpad-opfs-worker2.js 5f2237427ac537b8580b1c659ff14ad2621d1694043eaaf41ae18dbfef2e48c0
|
||||||
F ext/wasm/speedtest1-worker.html 23b91da39859b890d73b28bd74629442c6873f38dc4d7ca94cacdc1be1202fb1
|
F ext/wasm/speedtest1-worker.html 516f8434623e229d98554d34be64faeb9651083f20f2d0ebac2e67ea715574e8
|
||||||
F ext/wasm/speedtest1-worker.js 356b9953add4449acf199793db9b76b11ee016021918d8daffd19f08ec68d305
|
F ext/wasm/speedtest1-worker.js 356b9953add4449acf199793db9b76b11ee016021918d8daffd19f08ec68d305
|
||||||
F ext/wasm/speedtest1.html ffda8a118c09d5429bc34b1ddfd05a963b6786ac83f2deae4f5241c2f5437f83
|
F ext/wasm/speedtest1.html 8f61cbe68300acca25dd9fa74dce79b774786e2b4feeb9bcbc46e1cefbfa6262
|
||||||
F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x
|
F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x
|
||||||
F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
|
F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
|
||||||
F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5
|
F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5
|
||||||
@@ -2019,8 +2019,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 51395c005da46b7fa5a5f28809dd8fea263a6bac2b1492759b3d5a5aa7d399ca
|
P f2846dcbcaac7880394fb14597c3a60ed310419128c4c5b863cd771a7e5cdeb5
|
||||||
R 838553aa9700f04488b76fccfa35dc26
|
R 76ac17000a84c98911a70f4e46426ce1
|
||||||
U stephan
|
U stephan
|
||||||
Z 42d1e2550cb35842fb99b726ce6e4b2a
|
Z 8dd38cd18f4d355043f091ca5e469e89
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@@ -1 +1 @@
|
|||||||
f2846dcbcaac7880394fb14597c3a60ed310419128c4c5b863cd771a7e5cdeb5
|
02709ee2beab36d144b807fd9ffaee639e3c1bdd1908a34e05f3fd23dad2ef66
|
Reference in New Issue
Block a user