Skip to content

Conversation

@bontscho
Copy link

PR for #38

I kept the code I added as close to the code style of the existing code. To be a non-breaking update, I added the option includeDiffOnDataEquality and defaulted it to true. This allows for setting it to false if the diff is not wanted on strict equality.

For speed comparison, I put together a small benchmark script with the following results:

# Same Buffers ( comparing 1a.png with 1a.png)
$ node benchmark.js 1a 1a
before # Buffer(includeDiffOnDataEquality=true) x 256 ops/sec ±1.62% (84 runs sampled)
after # Buffer(includeDiffOnDataEquality=true) x 791 ops/sec ±2.16% (84 runs sampled)
before # Buffer(includeDiffOnDataEquality=false) x 254 ops/sec ±1.91% (83 runs sampled)
after # Buffer(includeDiffOnDataEquality=false) x 27,263 ops/sec ±2.59% (84 runs sampled)
before # identical Arrays (includeDiffOnDataEquality=false) x 55.60 ops/sec ±2.10% (57 runs sampled)
after # identical Arrays (includeDiffOnDataEquality=false) x 3,171 ops/sec ±2.79% (78 runs sampled)
before # identical Arrays (includeDiffOnDataEquality=true) x 55.62 ops/sec ±2.42% (63 runs sampled)
after # identical Arrays (includeDiffOnDataEquality=true) x 148 ops/sec ±1.80% (74 runs sampled)
before # different Arrays x 10.56 ops/sec ±3.22% (30 runs sampled)
after # different Arrays x 15.75 ops/sec ±2.23% (43 runs sampled)
Fastest is after # Buffer(includeDiffOnDataEquality=false)

# Different Buffers ( comparing 1a.png with 1b.png)
$ node benchmark.js 1a 1b
before # Buffer(includeDiffOnDataEquality=true) x 244 ops/sec ±2.06% (80 runs sampled)
after # Buffer(includeDiffOnDataEquality=true) x 250 ops/sec ±1.61% (83 runs sampled)
before # Buffer(includeDiffOnDataEquality=false) x 249 ops/sec ±1.81% (82 runs sampled)
after # Buffer(includeDiffOnDataEquality=false) x 246 ops/sec ±2.05% (81 runs sampled)
before # identical Arrays (includeDiffOnDataEquality=false) x 53.53 ops/sec ±1.91% (68 runs sampled)
after # identical Arrays (includeDiffOnDataEquality=false) x 2,879 ops/sec ±8.06% (71 runs sampled)
before # identical Arrays (includeDiffOnDataEquality=true) x 52.71 ops/sec ±2.40% (67 runs sampled)
after # identical Arrays (includeDiffOnDataEquality=true) x 149 ops/sec ±1.90% (74 runs sampled)
before # different Arrays x 10.48 ops/sec ±3.79% (30 runs sampled)
after # different Arrays x 14.74 ops/sec ±3.92% (40 runs sampled)
Fastest is after # identical Arrays (includeDiffOnDataEquality=false)

Looking forward to your feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant