codemix/fast.js — pull request #39 by phpnode (2014-06-29 12:17:54+00:00)
Title: add fast.apply()

A faster version of `Function::apply()`, optimised for 8 arguments or less. Benchmarks include our worst case where arguments length is greater than 8, in these cases you should just use the native `Function::apply()` as we're 10% slower than native.

#### V8 Benchmarks
```
Native .apply() vs fast.apply() (3 items, no context)
✓ Function::apply() x 21,396,321 ops/sec ±1.02% (89 runs sampled)
✓ fast.apply() x 31,848,833 ops/sec ±1.20% (77 runs sampled)

Result: fast.js is 48.85% faster than Function::apply().

Native .apply() vs fast.apply() (3 items, with context)
✓ Function::apply() x 19,504,564 ops/sec ±1.05% (91 runs sampled)
✓ fast.apply() x 25,195,224 ops/sec ±1.32% (84 runs sampled)

Result: fast.js is 29.18% faster than Function::apply().

Native .apply() vs fast.apply() (6 items, no context)
✓ Function::apply() x 20,690,649 ops/sec ±1.17% (89 runs sampled)
✓ fast.apply() x 31,852,556 ops/sec ±1.30% (86 runs sampled)

Result: fast.js is 53.95% faster than Function::apply().

Native .apply() vs fast.apply() (6 items, with context)
✓ Function::apply() x 15,525,290 ops/sec ±1.26% (90 runs sampled)
✓ fast.apply() x 20,977,452 ops/sec ±1.36% (88 runs sampled)

Result: fast.js is 35.12% faster than Function::apply().

Native .apply() vs fast.apply() (10 items, no context)
✓ Function::apply() x 14,092,003 ops/sec ±1.22% (83 runs sampled)
✓ fast.apply() x 12,572,608 ops/sec ±1.23% (89 runs sampled)

Result: fast.js is 10.78% slower than Function::apply().

Native .apply() vs fast.apply() (10 items, with context)
✓ Function::apply() x 13,740,157 ops/sec ±1.77% (90 runs sampled)
✓ fast.apply() x 11,518,081 ops/sec ±0.81% (85 runs sampled)

Result: fast.js is 16.17% slower than Function::apply().
```
#### SpiderMonkey Benchmarks
```
Native .apply() vs fast.apply() (3 items, no context)
✓ Function::apply() x 8,630,832 ops/sec ±0.37% (68 runs sampled)
✓ fast.apply() x 45,470,129 ops/sec ±0.25% (69 runs sampled)

Result: fast.js is 426.83% faster than Function::apply().

Native .apply() vs fast.apply() (3 items, with context)
✓ Function::apply() x 8,123,832 ops/sec ±0.21% (69 runs sampled)
✓ fast.apply() x 26,736,189 ops/sec ±0.44% (68 runs sampled)

Result: fast.js is 229.11% faster than Function::apply().

Native .apply() vs fast.apply() (6 items, no context)
✓ Function::apply() x 8,674,185 ops/sec ±0.26% (69 runs sampled)
✓ fast.apply() x 35,639,090 ops/sec ±0.26% (69 runs sampled)

Result: fast.js is 310.86% faster than Function::apply().

Native .apply() vs fast.apply() (6 items, with context)
✓ Function::apply() x 7,693,303 ops/sec ±0.24% (70 runs sampled)
✓ fast.apply() x 25,335,283 ops/sec ±0.24% (70 runs sampled)

Result: fast.js is 229.32% faster than Function::apply().

Native .apply() vs fast.apply() (10 items, no context)
✓ Function::apply() x 5,384,764 ops/sec ±0.31% (68 runs sampled)
✓ fast.apply() x 4,622,285 ops/sec ±1.32% (68 runs sampled)

Result: fast.js is 14.16% slower than Function::apply().

Native .apply() vs fast.apply() (10 items, with context)
✓ Function::apply() x 5,215,760 ops/sec ±0.50% (69 runs sampled)
✓ fast.apply() x 4,702,711 ops/sec ±1.46% (69 runs sampled)

Result: fast.js is 9.84% slower than Function::apply().
```