aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/wasm/batch-runner.html2
-rw-r--r--ext/wasm/batch-runner.js60
-rw-r--r--ext/wasm/demo-123.js2
-rw-r--r--ext/wasm/speedtest1-worker.html6
4 files changed, 18 insertions, 52 deletions
diff --git a/ext/wasm/batch-runner.html b/ext/wasm/batch-runner.html
index a07fe930a..e7a2b1e08 100644
--- a/ext/wasm/batch-runner.html
+++ b/ext/wasm/batch-runner.html
@@ -69,8 +69,6 @@
<label for='cb-reverse-log-order'>Reverse log order (newest first)</label>
</span>
<div id='test-output'></div>
- <!-- batch-runner.js "should" work with sqlite3-kvvfs so long as
- its data sets don't violate the the storage limits. -->
<script src="sqlite3-wasmfs.js"></script>
<script src="common/SqliteTestUtil.js"></script>
<script src="batch-runner.js"></script>
diff --git a/ext/wasm/batch-runner.js b/ext/wasm/batch-runner.js
index 36083e62f..c40157bb5 100644
--- a/ext/wasm/batch-runner.js
+++ b/ext/wasm/batch-runner.js
@@ -18,6 +18,11 @@
const toss = function(...args){throw new Error(args.join(' '))};
const warn = console.warn.bind(console);
let sqlite3;
+ const urlParams = new URL(self.location.href).searchParams;
+ const cacheSize = (()=>{
+ if(urlParams.has('cachesize')) return +urlParams.get('cachesize');
+ return 200;
+ })();
/** Throws if the given sqlite3 result code is not 0. */
const checkSqliteRc = (dbh,rc)=>{
@@ -63,51 +68,8 @@
// This would be SO much easier with the oo1 API, but we specifically want to
// inject metrics we can't get via that API, and we cannot reliably (OPFS)
// open the same DB twice to clear it using that API, so...
- let pStmt = 0, pSqlBegin;
- const capi = sqlite3.capi, wasm = capi.wasm;
- const scope = wasm.scopedAllocPush();
- try {
- const toDrop = [/* type, name pairs */];
- const ppStmt = wasm.scopedAllocPtr();
- // Collect list of tables/etc we can drop...
- let rc = capi.sqlite3_prepare_v2(db.handle, sqlToDrop, -1, ppStmt, null);
- checkSqliteRc(db.handle,rc);
- pStmt = wasm.getPtrValue(ppStmt);
- while(capi.SQLITE_ROW===capi.sqlite3_step(pStmt)){
- toDrop.push(capi.sqlite3_column_text(pStmt,0),
- capi.sqlite3_column_text(pStmt,1));
- }
- capi.sqlite3_finalize(pStmt);
- pStmt = 0;
- // Build SQL to delete them...
- const sqlDrop = [];
- const doDrop = 0!==toDrop.length;
- while(doDrop){
- const name = toDrop.pop();
- if(name){
- const type = toDrop.pop();
- switch(type){
- case 'table': case 'view': case 'trigger': case 'index':
- sqlDrop.push('DROP '+type+' '+name);
- break;
- default:
- warn("Unhandled db entry type:",type,name);
- continue;
- }
- }else{
- sqlDrop.push("VACUUM");
- break;
- }
- }
- if(sqlDrop.length){
- const sqlClean = sqlDrop.join(';\n');
- console.log("Cleaning up",db.id,":",sqlClean);
- capi.sqlite3_exec(db.handle, sqlClean, 0, 0, 0);
- }
- }finally{
- if(pStmt) capi.sqlite3_finalize(pStmt);
- wasm.scopedAllocPop(scope);
- }
+ const rc = sqlite3.capi.wasm.exports.sqlite3_wasm_db_reset(db.handle);
+ App.logHtml("reset db rc =",rc,db.id, db.filename);
};
@@ -521,6 +483,10 @@
if('websql' === dbId){
d.handle = self.openDatabase('batch-runner', '0.1', 'foo', 1024 * 1024 * 50);
d.clear = ()=>clearDbWebSQL(d);
+ d.handle.transaction(function(tx){
+ tx.executeSql("PRAGMA cache_size="+cacheSize);
+ App.logHtml(dbId,"cache_size =",cacheSize);
+ });
}else{
const capi = this.sqlite3.capi, wasm = capi.wasm;
const stack = wasm.scopedAllocPush();
@@ -531,6 +497,8 @@
const rc = capi.sqlite3_open_v2(d.filename, ppDb, oFlags, null);
pDb = wasm.getPtrValue(ppDb)
if(rc) toss("sqlite3_open_v2() failed with code",rc);
+ capi.sqlite3_exec(pDb, "PRAGMA cache_size="+cacheSize, 0, 0, 0);
+ this.logHtml(dbId,"cache_size =",cacheSize);
}catch(e){
if(pDb) capi.sqlite3_close_v2(pDb);
}finally{
@@ -540,7 +508,7 @@
d.clear = ()=>clearDbSqlite(d);
}
d.clear();
- this.logHtml("Opened db:",dbId);
+ this.logHtml("Opened db:",dbId,d.filename);
console.log("db =",d);
return d;
},
diff --git a/ext/wasm/demo-123.js b/ext/wasm/demo-123.js
index 67c1094f0..ff36aaf4e 100644
--- a/ext/wasm/demo-123.js
+++ b/ext/wasm/demo-123.js
@@ -45,7 +45,7 @@
const capi = sqlite3.capi/*C-style API*/,
oo = sqlite3.oo1/*high-level OO API*/;
log("sqlite3 version",capi.sqlite3_libversion(), capi.sqlite3_sourceid());
- const db = new oo.DB("/mydb.sqlite3");
+ const db = new oo.DB("/mydb.sqlite3",'ct');
log("transient db =",db.filename);
/**
Never(!) rely on garbage collection to clean up DBs and
diff --git a/ext/wasm/speedtest1-worker.html b/ext/wasm/speedtest1-worker.html
index 87c504f4b..2c05fe6b1 100644
--- a/ext/wasm/speedtest1-worker.html
+++ b/ext/wasm/speedtest1-worker.html
@@ -31,7 +31,7 @@
<div id='toolbar-select'>
<select id='select-flags' size='10' multiple></select>
<div>The following flags can be passed as URL parameters:
- vfs=NAME, size=N, journal=MODE
+ vfs=NAME, size=N, journal=MODE, cachesize=BYTES
</div>
</div>
<div class='toolbar-inner-vertical'>
@@ -183,7 +183,7 @@
const getSelectedFlags = ()=>{
const f = Array.prototype.map.call(eFlags.selectedOptions, (v)=>v.value);
[
- 'size', 'vfs', 'journal'
+ 'size', 'vfs', 'journal', 'cachesize'
].forEach(function(k){
if(urlParams.has(k)) f.push('--'+k, urlParams.get(k));
});
@@ -214,7 +214,7 @@
(e.g. --script FILE). */
flags["--autovacuum"] = "Enable AUTOVACUUM mode";
flags["--big-transactions"] = "Important for tests 410 and 510!";
- //flags["--cachesize"] = "N Set the cache size to N";
+ //flags["--cachesize"] = "N Set the cache size to N pages";
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";