aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/batch-runner.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-11-30 20:34:24 +0000
committerstephan <stephan@noemail.net>2023-11-30 20:34:24 +0000
commit68003d9f1807195955716abf3454a3bccd6d82a4 (patch)
tree502ae70f367424bf2a7cce8e1c9a4d61ce011097 /ext/wasm/batch-runner.js
parent48222bef664ad4b51cdadccfc44426c69a66a5f9 (diff)
downloadsqlite-68003d9f1807195955716abf3454a3bccd6d82a4.tar.gz
sqlite-68003d9f1807195955716abf3454a3bccd6d82a4.zip
Add a basic batch-mode SQL runner for the SAH Pool VFS, for use in comparing it against WebSQL. Bring the WebSQL batch runner up to date, noting that it cannot run without addition of an "origin trial" activation key from Google because that's now the only way to enable WebSQL in Chrome (that part is not checked in because that key is private). Minor code-adjacent cleanups.
FossilOrigin-Name: 883990e7938c1f63906300a6113f0fadce143913b7c384e8aeb5f886f0be7c62
Diffstat (limited to 'ext/wasm/batch-runner.js')
-rw-r--r--ext/wasm/batch-runner.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/ext/wasm/batch-runner.js b/ext/wasm/batch-runner.js
index ff287a66e..e7a322b7f 100644
--- a/ext/wasm/batch-runner.js
+++ b/ext/wasm/batch-runner.js
@@ -72,7 +72,6 @@
App.logHtml("reset db rc =",rc,db.id, db.filename);
};
-
const E = (s)=>document.querySelector(s);
const App = {
e: {
@@ -91,6 +90,15 @@
db: Object.create(null),
dbs: Object.create(null),
cache:{},
+ metrics: {
+ fileCount: 0,
+ runTimeMs: 0,
+ prepareTimeMs: 0,
+ stepTimeMs: 0,
+ stmtCount: 0,
+ strcpyMs: 0,
+ sqlBytes: 0
+ },
log: console.log.bind(console),
warn: console.warn.bind(console),
cls: function(){this.e.output.innerHTML = ''},
@@ -117,7 +125,6 @@
"Running",name,'('+sql.length,'bytes) using',db.id);
const capi = this.sqlite3.capi, wasm = this.sqlite3.wasm;
let pStmt = 0, pSqlBegin;
- const stack = wasm.scopedAllocPush();
const metrics = db.metrics = Object.create(null);
metrics.prepTotal = metrics.stepTotal = 0;
metrics.stmtCount = 0;
@@ -142,6 +149,11 @@
this.logHtml("Overhead (time - prep - step):",
(metrics.evalTimeTotal - metrics.prepTotal - metrics.stepTotal)+"ms");
this.logHtml(banner,"End of",name);
+ this.metrics.prepareTimeMs += metrics.prepTotal;
+ this.metrics.stepTimeMs += metrics.stepTotal;
+ this.metrics.stmtCount += metrics.stmtCount;
+ this.metrics.strcpyMs += metrics.strcpy;
+ this.metrics.sqlBytes += sql.length;
};
let runner;
@@ -214,7 +226,9 @@
}.bind(this);
}else{/*sqlite3 db...*/
runner = function(resolve, reject){
+ ++this.metrics.fileCount;
metrics.evalSqlStart = performance.now();
+ const stack = wasm.scopedAllocPush();
try {
let t;
let sqlByteLen = sql.byteLength;
@@ -269,7 +283,7 @@
let p;
if(1){
p = new Promise(function(res,rej){
- setTimeout(()=>runner(res, rej), 50)/*give UI a chance to output the "running" banner*/;
+ setTimeout(()=>runner(res, rej), 0)/*give UI a chance to output the "running" banner*/;
});
}else{
p = new Promise(runner);
@@ -401,7 +415,7 @@
});
return new Blob(ar);
},
-
+
downloadMetrics: function(){
const b = this.metricsToBlob();
if(!b) return;
@@ -576,6 +590,8 @@
const timeTotal = performance.now() - timeStart;
who.logHtml("Run-remaining time:",timeTotal,"ms ("+(timeTotal/1000/60)+" minute(s))");
who.clearStorage();
+ App.metrics.runTimeMs = timeTotal;
+ who.logHtml("Total metrics:",JSON.stringify(App.metrics,undefined,' '));
}, false);
}/*run()*/
}/*App*/;