Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rabin-stream #11

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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