Skip to content

Commit

Permalink
Upgrade Splice to 0.0.15.
Browse files Browse the repository at this point in the history
insert: 109, gather: 84

Closes #468.
  • Loading branch information
flatheadmill committed Feb 8, 2015
1 parent bf576a1 commit 9390fda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
24 changes: 10 additions & 14 deletions benchmark/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
___ usage ___
*/

var advance = require('advance')
var splice = require('splice')
var cadence = require('cadence/redux')
var path = require('path')
Expand All @@ -24,14 +23,15 @@ var random = (function () {
return Math.floor(random() * max)
}
})()
function recordSort (a, b) {
return a.key < b.key ? -1 : a.key > b.key ? 1 : 0
}

var runner = cadence(function (async) {
var start, insert, gather
var directory = path.join(__dirname, 'tmp'), db, count = 0
var extractor = function (record) { return record.key }
var strata = new Strata({
directory: directory,
extractor: extractor,
leafSize: 256,
branchSize: 256,
writeStage: 'leaf'
Expand All @@ -47,9 +47,11 @@ var runner = cadence(function (async) {
buffer = new Buffer(4)
buffer.writeUInt32BE(value, 0)
sha.update(buffer)
var digest = sha.digest('hex')
entries.push({
key: sha.digest('hex'),
type: !! random(2) ? 'insert' : 'delete'
key: digest,
type: !! random(2) ? 'insert' : 'delete',
record: digest
})
}
batches.push(entries)
Expand All @@ -62,14 +64,12 @@ var runner = cadence(function (async) {
start = Date.now()
strata.create(async())
}, function () {
var time
var batch = 0, loop = async(function () {
if (batch === 7) return [ loop ]
var iterator = advance(batches[batch], function (record, callback) {
callback(null, record, record.key)
})
splice(function (incoming, existing) {
return incoming.record.type
}, strata, iterator, async())
return incoming.type
}, strata, batches[batch], async())
batch++
})()
}, function () {
Expand Down Expand Up @@ -108,8 +108,4 @@ var runner = cadence(function (async) {

require('arguable/executable')(module, cadence(function (async, options) {
runner(options, async())
return
AsyncProfile.profile(function () {
runner(options, function (error) { if (error) throw error })
})
}))
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
{
"seedrandom": "2.3.10",
"proof": "0.0.50",
"advance": "0.0.8",
"rimraf": "~2.2",
"mkdirp": "~0.3",
"splice": "0.0.14",
"splice": "0.0.16",
"arguable": "0.0.22"
},
"licenses":
Expand Down

0 comments on commit 9390fda

Please sign in to comment.