Skip to content

Commit

Permalink
fix rabin-stream (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGraey committed Apr 1, 2020
1 parent 6d9d7e2 commit 8451abf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions benchmarks/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ const suite = new Benchmark.Suite();

// add tests
suite
.add('native rabin', {
.add('native rabin', {
defer: true,
fn:function(deferred) {
fn(deferred) {
const rabin = new Rabin()
const data = randomStream(100 * 1000 * 1024)
data.pipe(rabin)
rabin.on('data', () => {})

rabin.on('end', () => deferred.resolve())
}
})
.add('wasm rabin', {
.add('wasm rabin', {
defer: true,
fn: function(deferred) {
fn(deferred) {
const rabin = new RabinWasm()
const data = randomStream(100 * 1000 * 1024)
data.pipe(rabin)
rabin.on('data', () => {})
rabin.on('end', () => deferred.resolve())
}
})
// .add('js rabin', {
// .add('js rabin', {
// defer: true,
// fn: function(deferred) {
// fn(deferred) {
// const rabin = new RabinJs()
// const data = randomStream(100 * 1000 * 1024)
// data.pipe(rabin)
Expand Down
4 changes: 2 additions & 2 deletions cli/rabin-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function RabinStream (opts = {}) {
var avgBits = +opts.bits || 12
var min = +opts.min || 8 * 1024
var max = +opts.max || 32 * 1024
this.rabin = new Rabin(avgBits, min, max, 64, compiled)
this.rabin = new Rabin(compiled, avgBits, min, max, 64)
this.nextCb = null
this.buffers = new BufferList()
this.pending = []
Expand Down Expand Up @@ -63,7 +63,7 @@ RabinStream.prototype._write = function (data, enc, cb) {
RabinStream.prototype._process = function (cb) {
var drained = true
var sizes = this.rabin.fingerprint(Buffer.concat(this.pending))

this.pending = []

debug('chunks', sizes)
Expand Down

0 comments on commit 8451abf

Please sign in to comment.