aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/speedtest1-wasmfs.html
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/speedtest1-wasmfs.html')
-rw-r--r--ext/wasm/speedtest1-wasmfs.html168
1 files changed, 83 insertions, 85 deletions
diff --git a/ext/wasm/speedtest1-wasmfs.html b/ext/wasm/speedtest1-wasmfs.html
index 37155282c..6952fc1ee 100644
--- a/ext/wasm/speedtest1-wasmfs.html
+++ b/ext/wasm/speedtest1-wasmfs.html
@@ -39,115 +39,113 @@
<script src="common/SqliteTestUtil.js"></script>
<script src="speedtest1-wasmfs.js"></script>
<script>(function(){
- /**
- 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 wasmfsDir = function f(wasmUtil){
- if(undefined !== f._) return f._;
- const pdir = '/persistent';
- if( !self.FileSystemHandle
- || !self.FileSystemDirectoryHandle
- || !self.FileSystemFileHandle){
+ /**
+ 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 wasmfsDir = function f(wasmUtil,dirName="/opfs"){
+ if(undefined !== f._) return f._;
+ if( !self.FileSystemHandle
+ || !self.FileSystemDirectoryHandle
+ || !self.FileSystemFileHandle){
return f._ = "";
- }
- try{
+ }
+ try{
if(0===wasmUtil.xCallWrapped(
- 'sqlite3_wasm_init_wasmfs', 'i32', ['string'], pdir
+ 'sqlite3_wasm_init_wasmfs', 'i32', ['string'], dirName
)){
- return f._ = pdir;
+ return f._ = dirName;
}else{
- return f._ = "";
+ return f._ = "";
}
- }catch(e){
+ }catch(e){
// sqlite3_wasm_init_wasmfs() is not available
return f._ = "";
- }
- };
- wasmfsDir._ = undefined;
+ }
+ };
+ wasmfsDir._ = undefined;
- const eOut = document.querySelector('#test-output');
- const log2 = function(cssClass,...args){
- const ln = document.createElement('div');
- if(cssClass) ln.classList.add(cssClass);
- ln.append(document.createTextNode(args.join(' ')));
- eOut.append(ln);
- //this.e.output.lastElementChild.scrollIntoViewIfNeeded();
- };
- const logList = [];
- const dumpLogList = function(){
- logList.forEach((v)=>log2('',v));
- logList.length = 0;
- };
- /* can't update DOM while speedtest is running unless we run
- speedtest in a worker thread. */;
- const log = (...args)=>{
- console.log(...args);
- logList.push(args.join(' '));
- };
- const logErr = function(...args){
- console.error(...args);
- logList.push('ERROR: '+args.join(' '));
- };
+ const eOut = document.querySelector('#test-output');
+ const log2 = function(cssClass,...args){
+ const ln = document.createElement('div');
+ if(cssClass) ln.classList.add(cssClass);
+ ln.append(document.createTextNode(args.join(' ')));
+ eOut.append(ln);
+ //this.e.output.lastElementChild.scrollIntoViewIfNeeded();
+ };
+ const logList = [];
+ const dumpLogList = function(){
+ logList.forEach((v)=>log2('',v));
+ logList.length = 0;
+ };
+ /* can't update DOM while speedtest is running unless we run
+ speedtest in a worker thread. */;
+ const log = (...args)=>{
+ console.log(...args);
+ logList.push(args.join(' '));
+ };
+ const logErr = function(...args){
+ console.error(...args);
+ logList.push('ERROR: '+args.join(' '));
+ };
- const runTests = function(sqlite3){
- console.log("Module inited.");
- const wasm = sqlite3.capi.wasm;
- const unlink = wasm.xWrap("sqlite3_wasm_vfs_unlink", "int", ["string"]);
- const pDir = wasmfsDir(wasm);
- if(pDir) log2('',"Persistent storage:",pDir);
- else{
+ const runTests = function(sqlite3){
+ console.log("Module inited.");
+ const wasm = sqlite3.capi.wasm;
+ const unlink = wasm.xWrap("sqlite3_wasm_vfs_unlink", "int", ["string"]);
+ const pDir = wasmfsDir(wasm);
+ if(pDir) log2('',"Persistent storage:",pDir);
+ else{
log2('error',"Expecting persistent storage in this build.");
return;
- }
- const scope = wasm.scopedAllocPush();
- const dbFile = pDir+"/speedtest1.db";
- const urlParams = self.SqliteTestUtil.processUrlArgs();
- const argv = ["speedtest1"];
- if(urlParams.flags){
- argv.push(...(urlParams.flags.split(',')));
+ }
+ const scope = wasm.scopedAllocPush();
+ const dbFile = pDir+"/speedtest1.db";
+ const urlParams = new URL(self.location.href).searchParams;
+ const argv = ["speedtest1"];
+ if(urlParams.has('flags')){
+ argv.push(...(urlParams.get('flags').split(',')));
let i = argv.indexOf('--vfs');
if(i>=0) argv.splice(i,2);
- }else{
+ }else{
argv.push(
- "--singlethread",
- "--nomutex",
- "--nosync",
- "--nomemstat"
+ "--singlethread",
+ "--nomutex",
+ "--nosync",
+ "--nomemstat"
);
//"--memdb", // note that memdb trumps the filename arg
- }
+ }
- if(argv.indexOf('--memdb')>=0){
+ if(argv.indexOf('--memdb')>=0){
log2('error',"WARNING: --memdb flag trumps db filename.");
- }
- argv.push("--big-transactions"/*important for tests 410 and 510!*/,
- dbFile);
- console.log("argv =",argv);
- // 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.
- if(pDir) unlink(dbFile);
- 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(){
+ }
+ argv.push("--big-transactions"/*important for tests 410 and 510!*/,
+ dbFile);
+ console.log("argv =",argv);
+ // 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.
+ if(pDir) unlink(dbFile);
+ 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(){
wasm.xCall('wasm_main', argv.length,
wasm.scopedAllocMainArgv(argv));
wasm.scopedAllocPop(scope);
if(pDir) unlink(dbFile);
logList.unshift("Done running native main(). Output:");
dumpLogList();
- }, 25);
- }/*runTests()*/;
+ }, 25);
+ }/*runTests()*/;
- self.sqlite3TestModule.print = log;
- self.sqlite3TestModule.printErr = logErr;
- sqlite3Speedtest1InitModule(self.sqlite3TestModule).then(function(M){
- runTests(M.sqlite3);
- });
- })();
- </script>
+ self.sqlite3TestModule.print = log;
+ self.sqlite3TestModule.printErr = logErr;
+ sqlite3Speedtest1InitModule(self.sqlite3TestModule).then(function(M){
+ runTests(M.sqlite3);
+ });
+})();</script>
</body>
</html>