Alasql.js vs WebSQL (v9)

Revision 9 of this benchmark created by Meraj on


Description

Compare two browser databases Alasql (https://github.com/agershun/alasql) and WebSQL.

Preparation HTML

<script src="https://raw.githubusercontent.com/agershun/alasql/develop/dist/alasql.js"></script>
<script>
  var NUM_TESTS = 1000;

  // Generate SQL statements
  var sqls = [
    'DROP TABLE IF EXISTS test1',
    'DROP TABLE IF EXISTS test2',
    'CREATE TABLE test1 (one INT, two INT)',
    'CREATE TABLE test2 (two INT, three INT)'
  ];

  for (var i = 0; i < NUM_TESTS; i++) {
    sqls.push('INSERT INTO test1 VALUES (' + i % 10 + ',' + ((i * i) % 10) + ')');
    sqls.push('INSERT INTO test2 VALUES (' + i % 10 + ',' + ((i * i) % 10) + ')');
  }
  // Complex query
  var query = 'SELECT SUM(test1.one) AS sumone, test1.two, test2.three FROM test1 JOIN test2 ON test1.two = test2.two WHERE test1.one > 5 GROUP BY test1.two, test2.three ORDER BY three, sumone';

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
WebSQL
// async test
// Prepare WebSQL.JS database
var wdb = openDatabase('wdb', '0.1', 'Test database', 1000000);
wdb.transaction(function(tx) {
  sqls.forEach(function(sql) {
    tx.executeSql(sql);
  });
  tx.executeSql(query, [], function() {
    deferred.resolve();
  });
});
ready
Alasql
var adb = new alasql.Database();
sqls.forEach(function(sql) {
  adb.exec(sql);
});
adb.exec(query);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Andrey Gershun on
  • Revision 2: published on
  • Revision 3: published by Dre Headphones on
  • Revision 4: published by Peluang Usaha Yang Menjanjikan Ibu Rumah Tangga on
  • Revision 5: published by agershun on
  • Revision 6: published on
  • Revision 7: published by agershun on
  • Revision 8: published by mathiasrw on
  • Revision 9: published by Meraj on