[Pkg-javascript-commits] [node-leveldown] 114/492: added basic get() benchmarks

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:13:50 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 73d44f89005eaa163d480a26b37814dd165b3b87
Author: Rod Vagg <rod at vagg.org>
Date:   Sun Dec 16 13:20:35 2012 +1100

    added basic get() benchmarks
---
 test/benchmarks/engines/index.js                   |  4 +--
 test/benchmarks/index.js                           | 32 ++++++++++++++--------
 .../tests/get_int_string_x1000_leveled.js          | 16 +++++++++++
 .../tests/get_int_string_x1000_levelup.js          | 28 +++++++++++++++++++
 test/benchmarks/tests/index.js                     | 11 ++++++--
 5 files changed, 76 insertions(+), 15 deletions(-)

diff --git a/test/benchmarks/engines/index.js b/test/benchmarks/engines/index.js
index fa5bd6a..d835b53 100644
--- a/test/benchmarks/engines/index.js
+++ b/test/benchmarks/engines/index.js
@@ -4,8 +4,8 @@ module.exports.LevelUP.color = 'green'
 module.exports['LevelUP (release)'] = require('./levelup-release')
 module.exports['LevelUP (release)'].color = 'yellow'
 
-module.exports['LevelUP (no Snappy)'] = require('./levelup-nosnappy')
-module.exports['LevelUP (no Snappy)'].color = 'magenta'
+//module.exports['LevelUP (no Snappy)'] = require('./levelup-nosnappy')
+//module.exports['LevelUP (no Snappy)'].color = 'magenta'
 
 module.exports.Leveled = require('./leveled')
 module.exports.Leveled.color = 'cyan'
\ No newline at end of file
diff --git a/test/benchmarks/index.js b/test/benchmarks/index.js
index f45a8fc..225a5ae 100644
--- a/test/benchmarks/index.js
+++ b/test/benchmarks/index.js
@@ -28,17 +28,27 @@ var path = require('path')
     }
 
   , run = function (db, name, fn, color, cb) {
-      new Benchmark(name, {
-        'defer': true,
-        'fn': function  (deferred) {
-          fn(db, deferred.resolve.bind(deferred))
-        }
-      })
-      .on('complete', function(event) {
-        console.log(String(event.target)[color].bold)
-        cb()
-      })
-      .run({ async: true })
+      var exec = function () {
+        new Benchmark(name, {
+          'defer': true,
+          'fn': function  (deferred) {
+            fn(db, deferred.resolve.bind(deferred))
+          }
+        })
+        .on('complete', function(event) {
+          console.log(String(event.target)[color].bold)
+          cb()
+        })
+        .run({ async: true })
+      }
+
+      if (fn.setup) {
+        fn.setup(db, function (err) {
+          if (err) return cb(err)
+          exec()
+        })
+      } else
+        exec()
     }
 
   , runTest = function (testName, callback) {
diff --git a/test/benchmarks/tests/get_int_string_x1000_leveled.js b/test/benchmarks/tests/get_int_string_x1000_leveled.js
new file mode 100644
index 0000000..bf5539c
--- /dev/null
+++ b/test/benchmarks/tests/get_int_string_x1000_leveled.js
@@ -0,0 +1,16 @@
+var setupFn = function (count, db, cb) {
+  var data = []
+    , batch = db.batch()
+
+
+  for (var i = 0; i < count; i++)
+    batch.put(
+        String(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."
+    )
+
+  batch.write(cb)
+}
+
+module.exports = require('./get_int_string_x1000_levelup').bind(null) // bind() to make a new function to put .setup on
+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
new file mode 100644
index 0000000..3d41099
--- /dev/null
+++ b/test/benchmarks/tests/get_int_string_x1000_levelup.js
@@ -0,0 +1,28 @@
+var setupFn = function (count, db, cb) {
+      var data = []
+
+      for (var i = 0; i < count; i++)
+        data.push({
+            type: 'put'
+          , key: String(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 (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(String(i), after)
+    }
+
+
+module.exports = fn.bind(null, 1000)
+module.exports.fn = fn
+module.exports.setup = setupFn.bind(null, 1000)
\ No newline at end of file
diff --git a/test/benchmarks/tests/index.js b/test/benchmarks/tests/index.js
index 66805d3..39ab272 100644
--- a/test/benchmarks/tests/index.js
+++ b/test/benchmarks/tests/index.js
@@ -17,17 +17,24 @@ module.exports = {
       , 'Leveled'             : require('./put_int_string_x100000_leveled')
     }
 
+  , '=>get(int):string x 1000': {
+        'LevelUP'             : require('./get_int_string_x1000_levelup')
+      , 'LevelUP (release)'   : require('./get_int_string_x1000_levelup')
+      , 'LevelUP (no Snappy)' : require('./get_int_string_x1000_levelup')
+      , 'Leveled'             : require('./get_int_string_x1000_leveled')
+    }
+
   , 'batch(int, string) x 1000': {
         'LevelUP'             : require('./batch_int_string_x1000_levelup')
       , 'LevelUP (release)'   : require('./batch_int_string_x1000_levelup')
       , 'LevelUP (no Snappy)' : require('./batch_int_string_x1000_levelup')
-      , 'Leveled'             : require('./batch_int_string_x1000_leveled')
+//      , 'Leveled'             : require('./batch_int_string_x1000_leveled')
     }
 
   , 'batch(int, string) x 100,000': {
         'LevelUP'             : require('./batch_int_string_x100000_levelup')
       , 'LevelUP (release)'   : require('./batch_int_string_x100000_levelup')
       , 'LevelUP (no Snappy)' : require('./batch_int_string_x100000_levelup')
-      , 'Leveled'             : require('./batch_int_string_x100000_leveled')
+//      , 'Leveled'             : require('./batch_int_string_x100000_leveled')
     }
 }
\ 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