feross/buffer — pull request #21 by mafintosh (2014-04-05 18:28:36+00:00)
Title: Use native copy to speed up performance

First off - this module is awesome!

I've added native TypedArray copy for `Buffer.prototype.copy`.

The result when running the benchmarks is an dramatic performance increase when running copy on large buffers (50x on my machine!). I've also added a benchmark for running copy on 10k buffers.

Results running the `copy-big.js` bench in Chrome 33:
```
NewBuffer#copy x 2,576,007 ops/sec ±0.86% (68 runs sampled) copy-big.js:31
OldBuffer#copy x 12,428 ops/sec ±0.62% (68 runs sampled) copy-big.js:31
Buffer#copy x 44,412 ops/sec ±0.48% (70 runs sampled) copy-big.js:31
Fastest is NewBuffer#copy
```
`Buffer#copy` is the current version of this module and `NewBuffer#copy` is using my PR

This currently only uses the native method for buffers larger than 100 bytes (the benchmarks seems to show that old way is faster for very small buffers)