[Pkg-javascript-commits] [node-leveldown] 121/492: added SQLite3 to test suite

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:13:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit 635d12b6a54010f7d883f1a26b5e1485afb20175
Author: Rod Vagg <rod at vagg.org>
Date:   Sun Dec 16 19:23:41 2012 +1100

    added SQLite3 to test suite
---
 test/benchmarks/benchmarks.js                      | 137 ---------------------
 test/benchmarks/engines/index.js                   |   5 +-
 test/benchmarks/engines/sqlite3.js                 |  21 ++++
 test/benchmarks/package.json                       |   3 +-
 .../tests/get_int_string_x1000_leveled.js          |   6 +-
 .../tests/get_int_string_x1000_levelup.js          |   3 +-
 .../tests/get_int_string_x1000_sqlite3.js          |  33 +++++
 .../benchmarks/tests/get_int_string_x10_leveled.js |   2 +
 .../benchmarks/tests/get_int_string_x10_levelup.js |   2 +
 .../benchmarks/tests/get_int_string_x10_sqlite3.js |   2 +
 test/benchmarks/tests/index.js                     |  21 +++-
 .../tests/put_int_string_x100000_sqlite3.js        |   1 +
 .../tests/put_int_string_x1000_sqlite3.js          |  22 ++++
 .../benchmarks/tests/put_int_string_x10_leveled.js |   1 +
 .../benchmarks/tests/put_int_string_x10_levelup.js |   1 +
 .../benchmarks/tests/put_int_string_x10_sqlite3.js |   1 +
 16 files changed, 116 insertions(+), 145 deletions(-)

diff --git a/test/benchmarks/benchmarks.js b/test/benchmarks/benchmarks.js
deleted file mode 100644
index 773fcaf..0000000
--- a/test/benchmarks/benchmarks.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * `exports` is a map of benchmark name to benchmark function:
- *    'name': function (database, callback) { callback() }
- * If a benchmark needs a setup function then it should take the form:
- *    'name': {
- *        'setup': function (database, callback) { callback() }
- *      , 'fn': function (database, callback) { callback() }
- *    }
- *
- * The setup function and the benchmark function both receive a new and empty
- * instance of LevelUP which will be deleted after the benchmark is executed.
- *
- * The setup function will only be run once but the benchmark function will
- * be run multiple times to get a good sample. You can store values on `this`
- * across separate cycles so use it to avoid conflicts in `put()` for example.
- */
-
-module.exports = {
-
-    // Simple put() operation, 1000 objects at a time
-
-    'LevelUP#put(int, string) x 1000': function (db, cb) {
-      var puts = 1000
-        , received = 0
-        , after = function (err) {
-            if (err) throw err
-            if (++received == puts) cb()
-          }
-
-      if (this.cycle == null) this.cycle = 0
-      else this.cycle++
-
-      for (var i = 0; i < puts; i++)
-        db.put(
-            this.cycle * puts + i
-          , "It'll be top end no worries stands out like a bushie. It'll be cream no dramas flat out like a rotten. As busy as a slabs bloody built like a stonkered. Get a dog up ya oldies no dramas lets get some bottle-o. Built like a schooner as busy as a big smoke. You little ripper ute my you little ripper dag."
-          , after
-        )
-    }
-
-    // Simple put() operation, 100,000 objects at a time
-
-  , 'LevelUP#put(int, string) x 100,000': function (db, cb) {
-      var puts = 100000
-        , received = 0
-        , after = function (err) {
-            if (err) throw err
-            if (++received == puts) cb()
-          }
-
-      if (this.cycle == null) this.cycle = 0
-      else this.cycle++
-
-      for (var i = 0; i < puts; i++)
-        db.put(
-            this.cycle * puts + i
-          , "It'll be top end no worries stands out like a bushie. It'll be cream no dramas flat out like a rotten. As busy as a slabs bloody built like a stonkered. Get a dog up ya oldies no dramas lets get some bottle-o. Built like a schooner as busy as a big smoke. You little ripper ute my you little ripper dag."
-          , after
-        )
-    }
-
-    // Single put as batch() operation, 1000 objects at a time
-
-  , 'LevelUP#batch({put, int, string}) x 1000': function (db, cb) {
-      var puts = 1000
-        , received = 0
-        , after = function (err) {
-            if (err) throw err
-            if (++received == puts) cb()
-          }
-
-      if (this.cycle == null) this.cycle = 0
-      else this.cycle++
-
-      for (var i = 0; i < puts; i++)
-        db.batch(
-            [{
-                type: 'put'
-              , key: this.cycle * puts + i
-              , value: "It'll be top end no worries stands out like a bushie. It'll be cream no dramas flat out like a rotten. As busy as a slabs bloody built like a stonkered. Get a dog up ya oldies no dramas lets get some bottle-o. Built like a schooner as busy as a big smoke. You little ripper ute my you little ripper dag."
-            }]
-          , after
-        )
-    }
-
-    // Single put as batch() operation, 1000 objects at a time
-
-  , 'LevelUP#batch({put, int, string}) x 100,000': function (db, cb) {
-      var puts = 100000
-        , received = 0
-        , after = function (err) {
-            if (err) throw err
-            if (++received == puts) cb()
-          }
-
-      if (this.cycle == null) this.cycle = 0
-      else this.cycle++
-
-      for (var i = 0; i < puts; i++)
-        db.batch(
-            [{
-                type: 'put'
-              , key: this.cycle * puts + i
-              , value: "It'll be top end no worries stands out like a bushie. It'll be cream no dramas flat out like a rotten. As busy as a slabs bloody built like a stonkered. Get a dog up ya oldies no dramas lets get some bottle-o. Built like a schooner as busy as a big smoke. You little ripper ute my you little ripper dag."
-            }]
-          , after
-        )
-    }
-
-  , 'LevelUP#get(int) x 1000': {
-        'setup': function (db, cb) {
-          var count = 1000
-            , data = []
-
-          for (var i = 0; i < count; i++)
-            data.push({
-                type: 'put'
-              , key: i
-              , value: "It'll be top end no worries stands out like a bushie. It'll be cream no dramas flat out like a rotten. As busy as a slabs bloody built like a stonkered. Get a dog up ya oldies no dramas lets get some bottle-o. Built like a schooner as busy as a big smoke. You little ripper ute my you little ripper dag."
-            })
-
-          db.batch(data, cb)
-        }
-
-      , 'fn': function (db, cb) {
-          var count = 1000
-            , received = 0
-            , after = function (err) {
-                if (err) throw err
-                if (++received == count) cb()
-              }
-
-          for (var i = 0; i < count; i++)
-            db.get(i, after)
-        }
-    }
-}
\ No newline at end of file
diff --git a/test/benchmarks/engines/index.js b/test/benchmarks/engines/index.js
index d835b53..99a87e2 100644
--- a/test/benchmarks/engines/index.js
+++ b/test/benchmarks/engines/index.js
@@ -8,4 +8,7 @@ module.exports['LevelUP (release)'].color = 'yellow'
 //module.exports['LevelUP (no Snappy)'].color = 'magenta'
 
 module.exports.Leveled = require('./leveled')
-module.exports.Leveled.color = 'cyan'
\ No newline at end of file
+module.exports.Leveled.color = 'cyan'
+
+module.exports.SQLite3 = require('./sqlite3')
+module.exports.SQLite3.color = 'blue'
\ No newline at end of file
diff --git a/test/benchmarks/engines/sqlite3.js b/test/benchmarks/engines/sqlite3.js
new file mode 100644
index 0000000..d5599a1
--- /dev/null
+++ b/test/benchmarks/engines/sqlite3.js
@@ -0,0 +1,21 @@
+var sqlite3 = require('sqlite3')
+
+  , createDb = function (location, callback) {
+      var db = new sqlite3.Database(location, function (err) {
+        if (err) return callback(err)
+        db.run("CREATE TABLE bench (key VARCHAR(32), value TEXT)", function (err) {
+          if (err) return callback(err)
+          setTimeout(callback.bind(null, null, db), 50)
+        })
+      })
+    }
+
+  , closeDb = function (db, callback) {
+      db.close() // does it have a callback?
+      setTimeout(callback, 50)
+    }
+
+module.exports = {
+    createDb : createDb
+  , closeDb  : closeDb
+}
\ No newline at end of file
diff --git a/test/benchmarks/package.json b/test/benchmarks/package.json
index f95f8af..11f0ad9 100644
--- a/test/benchmarks/package.json
+++ b/test/benchmarks/package.json
@@ -11,5 +11,6 @@
       , "async": "~0.1.22"
       , "levelup": "*"
       , "leveled": "*"
+      , "sqlite3": "*"
     }
-}
+}
\ No newline at end of file
diff --git a/test/benchmarks/tests/get_int_string_x1000_leveled.js b/test/benchmarks/tests/get_int_string_x1000_leveled.js
index bf5539c..68b49a4 100644
--- a/test/benchmarks/tests/get_int_string_x1000_leveled.js
+++ b/test/benchmarks/tests/get_int_string_x1000_leveled.js
@@ -1,8 +1,5 @@
 var setupFn = function (count, db, cb) {
-  var data = []
-    , batch = db.batch()
-
-
+  var batch = db.batch()
   for (var i = 0; i < count; i++)
     batch.put(
         String(i)
@@ -13,4 +10,5 @@ var setupFn = function (count, db, cb) {
 }
 
 module.exports = require('./get_int_string_x1000_levelup').bind(null) // bind() to make a new function to put .setup on
+module.exports.setupFn = setupFn
 module.exports.setup = setupFn.bind(null, 1000)
\ No newline at end of file
diff --git a/test/benchmarks/tests/get_int_string_x1000_levelup.js b/test/benchmarks/tests/get_int_string_x1000_levelup.js
index 3d41099..22c1bf8 100644
--- a/test/benchmarks/tests/get_int_string_x1000_levelup.js
+++ b/test/benchmarks/tests/get_int_string_x1000_levelup.js
@@ -25,4 +25,5 @@ var setupFn = function (count, db, cb) {
 
 module.exports = fn.bind(null, 1000)
 module.exports.fn = fn
-module.exports.setup = setupFn.bind(null, 1000)
\ No newline at end of file
+module.exports.setup = setupFn.bind(null, 1000)
+module.exports.setupFn = setupFn
\ No newline at end of file
diff --git a/test/benchmarks/tests/get_int_string_x1000_sqlite3.js b/test/benchmarks/tests/get_int_string_x1000_sqlite3.js
new file mode 100644
index 0000000..5316856
--- /dev/null
+++ b/test/benchmarks/tests/get_int_string_x1000_sqlite3.js
@@ -0,0 +1,33 @@
+var async = require('async')
+
+  , setupFn = function (count, db, cb) {
+      var queue = async.queue(function (key, callback) {
+        db.exec(
+            'INSERT INTO bench VALUES('
+          + key
+          + ', "It\'ll be top end no worries stands out like a bushie. It\'ll be cream no dramas flat out like a rotten. As busy as a slabs bloody built like a stonkered. Get a dog up ya oldies no dramas lets get some bottle-o. Built like a schooner as busy as a big smoke. You little ripper ute my you little ripper dag."'
+          + ')'
+          , callback
+        )
+      }, 20)
+      queue.drain = cb
+      for (var i = 0; i < count; i++)
+        queue.push(String(i))
+    }
+
+  , fn = function (count, db, cb) {
+      var received = 0
+        , after = function (err) {
+            if (err) throw err
+            if (++received == count) cb()
+          }
+
+      for (var i = 0; i < count; i++)
+        db.get('SELECT value FROM bench WHERE key = "' + i + '"', after)
+    }
+
+
+module.exports = fn.bind(null, 1000)
+module.exports.fn = fn
+module.exports.setup = setupFn.bind(null, 1000)
+module.exports.setupFn = setupFn
\ No newline at end of file
diff --git a/test/benchmarks/tests/get_int_string_x10_leveled.js b/test/benchmarks/tests/get_int_string_x10_leveled.js
new file mode 100644
index 0000000..913df45
--- /dev/null
+++ b/test/benchmarks/tests/get_int_string_x10_leveled.js
@@ -0,0 +1,2 @@
+module.exports = require('./get_int_string_x1000_levelup').fn.bind(null, 10)
+module.exports.setup = require('./get_int_string_x1000_leveled').setupFn.bind(null, 10)
\ No newline at end of file
diff --git a/test/benchmarks/tests/get_int_string_x10_levelup.js b/test/benchmarks/tests/get_int_string_x10_levelup.js
new file mode 100644
index 0000000..3b5f6ea
--- /dev/null
+++ b/test/benchmarks/tests/get_int_string_x10_levelup.js
@@ -0,0 +1,2 @@
+module.exports = require('./get_int_string_x1000_levelup').fn.bind(null, 10)
+module.exports.setup = require('./get_int_string_x1000_levelup').setupFn.bind(null, 10)
\ No newline at end of file
diff --git a/test/benchmarks/tests/get_int_string_x10_sqlite3.js b/test/benchmarks/tests/get_int_string_x10_sqlite3.js
new file mode 100644
index 0000000..0b40d50
--- /dev/null
+++ b/test/benchmarks/tests/get_int_string_x10_sqlite3.js
@@ -0,0 +1,2 @@
+module.exports = require('./get_int_string_x1000_sqlite3').fn.bind(null, 10)
+module.exports.setup = require('./get_int_string_x1000_sqlite3').setupFn.bind(null, 10)
\ No newline at end of file
diff --git a/test/benchmarks/tests/index.js b/test/benchmarks/tests/index.js
index d69a607..245706e 100644
--- a/test/benchmarks/tests/index.js
+++ b/test/benchmarks/tests/index.js
@@ -3,11 +3,20 @@
  */
 
 module.exports = {
-    'put(int, string) x 1000': {
+    'put(int, string) x 10': {
+        'LevelUP'             : require('./put_int_string_x10_levelup')
+      , 'LevelUP (release)'   : require('./put_int_string_x10_levelup')
+      , 'LevelUP (no Snappy)' : require('./put_int_string_x10_levelup')
+      , 'Leveled'             : require('./put_int_string_x10_leveled')
+      , 'SQLite3'             : require('./put_int_string_x10_sqlite3')
+    }
+
+  , 'put(int, string) x 1000': {
         'LevelUP'             : require('./put_int_string_x1000_levelup')
       , 'LevelUP (release)'   : require('./put_int_string_x1000_levelup')
       , 'LevelUP (no Snappy)' : require('./put_int_string_x1000_levelup')
       , 'Leveled'             : require('./put_int_string_x1000_leveled')
+      , 'SQLite3'             : require('./put_int_string_x1000_sqlite3')
     }
 
   , 'put(int, string) x 100,000': {
@@ -15,6 +24,15 @@ module.exports = {
       , 'LevelUP (release)'   : require('./put_int_string_x100000_levelup')
       , 'LevelUP (no Snappy)' : require('./put_int_string_x100000_levelup')
       , 'Leveled'             : require('./put_int_string_x100000_leveled')
+      // too slow , 'SQLite3'             : require('./put_int_string_x100000_sqlite3')
+    }
+
+  , 'get(int):string x 10': {
+        'LevelUP'             : require('./get_int_string_x10_levelup')
+      , 'LevelUP (release)'   : require('./get_int_string_x10_levelup')
+      , 'LevelUP (no Snappy)' : require('./get_int_string_x10_levelup')
+      , 'Leveled'             : require('./get_int_string_x10_leveled')
+      , 'SQLite3'             : require('./get_int_string_x10_sqlite3')
     }
 
   , 'get(int):string x 1000': {
@@ -22,6 +40,7 @@ module.exports = {
       , 'LevelUP (release)'   : require('./get_int_string_x1000_levelup')
       , 'LevelUP (no Snappy)' : require('./get_int_string_x1000_levelup')
       , 'Leveled'             : require('./get_int_string_x1000_leveled')
+      , 'SQLite3'             : require('./get_int_string_x1000_sqlite3')
     }
 
   , 'batch(int, string) x 1000': {
diff --git a/test/benchmarks/tests/put_int_string_x100000_sqlite3.js b/test/benchmarks/tests/put_int_string_x100000_sqlite3.js
new file mode 100644
index 0000000..d65c35f
--- /dev/null
+++ b/test/benchmarks/tests/put_int_string_x100000_sqlite3.js
@@ -0,0 +1 @@
+module.exports = require('./put_int_string_x1000_sqlite3').fn.bind(null, 100000)
\ No newline at end of file
diff --git a/test/benchmarks/tests/put_int_string_x1000_sqlite3.js b/test/benchmarks/tests/put_int_string_x1000_sqlite3.js
new file mode 100644
index 0000000..64af34b
--- /dev/null
+++ b/test/benchmarks/tests/put_int_string_x1000_sqlite3.js
@@ -0,0 +1,22 @@
+var fn = function (puts, db, cb) {
+  var received = 0
+    , after = function (err) {
+        if (err) throw err
+        if (++received == puts) cb()
+      }
+
+  if (this.cycle == null) this.cycle = 0
+  else this.cycle++
+
+  for (var i = 0; i < puts; i++)
+    db.exec(
+        'INSERT INTO bench VALUES('
+      + String(this.cycle * puts + i)
+      + ', "It\'ll be top end no worries stands out like a bushie. It\'ll be cream no dramas flat out like a rotten. As busy as a slabs bloody built like a stonkered. Get a dog up ya oldies no dramas lets get some bottle-o. Built like a schooner as busy as a big smoke. You little ripper ute my you little ripper dag."'
+      + ')'
+      , after
+    )
+}
+
+module.exports = fn.bind(null, 1000)
+module.exports.fn = fn
\ No newline at end of file
diff --git a/test/benchmarks/tests/put_int_string_x10_leveled.js b/test/benchmarks/tests/put_int_string_x10_leveled.js
new file mode 100644
index 0000000..1832a4a
--- /dev/null
+++ b/test/benchmarks/tests/put_int_string_x10_leveled.js
@@ -0,0 +1 @@
+module.exports = require('./put_int_string_x10_levelup')
\ No newline at end of file
diff --git a/test/benchmarks/tests/put_int_string_x10_levelup.js b/test/benchmarks/tests/put_int_string_x10_levelup.js
new file mode 100644
index 0000000..c72cf4f
--- /dev/null
+++ b/test/benchmarks/tests/put_int_string_x10_levelup.js
@@ -0,0 +1 @@
+module.exports = require('./put_int_string_x1000_levelup').fn.bind(null, 10)
\ No newline at end of file
diff --git a/test/benchmarks/tests/put_int_string_x10_sqlite3.js b/test/benchmarks/tests/put_int_string_x10_sqlite3.js
new file mode 100644
index 0000000..a861217
--- /dev/null
+++ b/test/benchmarks/tests/put_int_string_x10_sqlite3.js
@@ -0,0 +1 @@
+module.exports = require('./put_int_string_x1000_sqlite3').fn.bind(null, 10)
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list