This new API release provides major benefits including optimized support for concurrent database access, drastic performance improvements, API simplification, and codebase modernization.
according to SQLCipher: 59.59 sec vs 3.01 sec (Pixel 6):
source: SQLCipher
My tests:
normal: 10.05 sec
4.1.0: 54.5 sec
5.0.0: 39.5 sec
var DB = require('appcelerator.encrypteddatabase');
var instance = null;
var dataTofetch = null;
var win = Ti.UI.createWindow();
var lbl = Ti.UI.createLabel();
var timeStart = 0;
win.addEventListener('open', function() {
timeStart = new Date();
init();
setup();
insert();
fetch();
closeDB();
lbl.text = ((new Date()) - timeStart) / 1000 + " sec";
});
function init() {
DB.password = 'secret';
Ti.API.info('Opening DB ...');
// instance = Ti.Database.open('myDatabase'); // use normal database
instance = DB.open('test.db');
}
function setup() {
console.log("setup");
instance.execute('CREATE TABLE IF NOT EXISTS testtable(id integer PRIMARY KEY);');
for (var i = 0; i < 10000; ++i) {
console.log("adding row " + i);
instance.execute('INSERT OR IGNORE INTO testtable(id) VALUES (' + i + ');');
}
}
function insert() {
console.log("insert");
var dataToInsertHandle = instance.execute('SELECT id FROM testtable ORDER BY id DESC LIMIT 1;');
var dataToInsert = null;
if (dataToInsertHandle.isValidRow()) {
dataToInsert = (dataToInsertHandle.fieldByName('id') + 1);
dataTofetch = dataToInsert;
}
instance.execute('INSERT OR IGNORE INTO testtable(id) VALUES (' + dataToInsert + ');');
for (var i = dataToInsert; i < dataToInsert + 10000; ++i) {
console.log("adding row " + i);
instance.execute('INSERT OR IGNORE INTO testtable(id) VALUES (' + i + ');');
}
}
function fetch() {
console.log("read");
var rowValue = null;
for (var i = 0; i < 10000; ++i) {
var dataTofetch = Math.round(Math.random() * 10000);
var rowHandle = instance.execute('SELECT * FROM testtable WHERE id=' + dataTofetch + ';');
if (rowHandle.isValidRow()) {
rowValue = rowHandle.fieldByName('id');
console.log("got value: " + rowValue);
}
}
}
function closeDB() {
instance.close();
}
win.add(lbl);
win.open();
Android
SQLCipher 4.5.4
(https://github.com/sqlcipher/sqlcipher/blob/master/CHANGELOG.md#454---april-2023---454-changes)pageSize
property.iOS
Binary: appcelerator.encrypteddatabase-android-5.0.1.zip
appcelerator.encrypteddatabase-iphone-4.0.1.zip
according to SQLCipher: 59.59 sec vs 3.01 sec (Pixel 6):
My tests: