codemix/fast.js — pull request #43 by phpnode (2014-06-30 12:29:50+00:00)
Title: add fromIndex to .indexOf() and .lastIndexOf()

On tiny arrays this has a performance impact compared to the last version, especially in SpiderMonkey, but this is arguably outweighed by the gains it provides when a `fromIndex` is specified. I think it makes sense to support it, so unless there are strong objections I'll merge this later on.

Fixes #15
Fixes #41
Closes #26 (cannot make the proposed change while supporting too `fromIndex`)

#### V8
```
Native .indexOf() vs fast.indexOf() (3 items)
✓ Array::indexOf() x 17,560,658 ops/sec ±2.56% (85 runs sampled)
✓ fast.indexOf() x 22,463,668 ops/sec ±1.58% (89 runs sampled)
✓ fast.indexOf() v0.0.2 x 26,450,192 ops/sec ±1.75% (83 runs sampled)
✓ underscore.indexOf() x 13,099,785 ops/sec ±1.41% (89 runs sampled)
✓ lodash.indexOf() x 18,553,491 ops/sec ±1.37% (87 runs sampled)

Result: fast.js is 27.92% faster than Array::indexOf().

Native .indexOf() vs fast.indexOf() (10 items)
✓ Array::indexOf() x 13,044,260 ops/sec ±1.40% (85 runs sampled)
✓ fast.indexOf() x 15,683,306 ops/sec ±1.43% (90 runs sampled)
✓ fast.indexOf() v0.0.2 x 18,210,071 ops/sec ±1.85% (85 runs sampled)
✓ underscore.indexOf() x 10,178,645 ops/sec ±1.69% (85 runs sampled)
✓ lodash.indexOf() x 12,911,221 ops/sec ±1.65% (91 runs sampled)

Result: fast.js is 20.23% faster than Array::indexOf().

Native .indexOf() vs fast.indexOf() (1000 items)
✓ Array::indexOf() x 356,802 ops/sec ±1.98% (87 runs sampled)
✓ fast.indexOf() x 360,638 ops/sec ±1.97% (87 runs sampled)
✓ fast.indexOf() v0.0.2 x 355,536 ops/sec ±1.87% (83 runs sampled)
✓ underscore.indexOf() x 348,486 ops/sec ±1.91% (87 runs sampled)
✓ lodash.indexOf() x 326,923 ops/sec ±2.19% (90 runs sampled)

Result: fast.js is 1.08% faster than Array::indexOf().

Native .lastIndexOf() vs fast.lastIndexOf() (3 items)
✓ Array::lastIndexOf() x 31,717,783 ops/sec ±1.33% (91 runs sampled)
✓ fast.lastIndexOf() x 42,430,953 ops/sec ±1.53% (90 runs sampled)
✓ fast.lastIndexOf() v0.0.2 x 51,392,630 ops/sec ±1.18% (82 runs sampled)
✓ underscore.lastIndexOf() x 22,564,488 ops/sec ±1.79% (79 runs sampled)
✓ lodash.lastIndexOf() x 39,301,938 ops/sec ±2.03% (88 runs sampled)

Result: fast.js is 33.78% faster than Array::lastIndexOf().

Native .lastIndexOf() vs fast.lastIndexOf() (10 items)
✓ Array::lastIndexOf() x 16,883,093 ops/sec ±1.39% (89 runs sampled)
✓ fast.lastIndexOf() x 24,116,874 ops/sec ±1.59% (86 runs sampled)
✓ fast.lastIndexOf() v0.0.2 x 28,413,574 ops/sec ±1.78% (84 runs sampled)
✓ underscore.lastIndexOf() x 11,314,195 ops/sec ±1.86% (82 runs sampled)
✓ lodash.lastIndexOf() x 22,576,656 ops/sec ±1.08% (85 runs sampled)

Result: fast.js is 42.85% faster than Array::lastIndexOf().

Native .lastIndexOf() vs fast.lastIndexOf() (1000 items)
✓ Array::lastIndexOf() x 805,980 ops/sec ±1.27% (89 runs sampled)
✓ fast.lastIndexOf() x 910,968 ops/sec ±1.70% (84 runs sampled)
✓ fast.lastIndexOf() v0.0.2 x 901,817 ops/sec ±1.84% (87 runs sampled)
✓ underscore.lastIndexOf() x 768,982 ops/sec ±1.67% (86 runs sampled)
✓ lodash.lastIndexOf() x 810,997 ops/sec ±1.48% (88 runs sampled)

Result: fast.js is 13.03% faster than Array::lastIndexOf().

```
#### SpiderMonkey
```
Native .indexOf() vs fast.indexOf() (3 items)
✓ Array::indexOf() x 25,517,880 ops/sec ±0.58% (68 runs sampled)
✓ fast.indexOf() x 36,082,347 ops/sec ±0.42% (68 runs sampled)
✓ fast.indexOf() v0.0.2 x 94,648,712 ops/sec ±0.55% (66 runs sampled)
✓ underscore.indexOf() x 495,123 ops/sec ±0.62% (38 runs sampled)
✓ lodash.indexOf() x 40,714,040 ops/sec ±0.39% (68 runs sampled)

Result: fast.js is 41.40% faster than Array::indexOf().

Native .indexOf() vs fast.indexOf() (10 items)
✓ Array::indexOf() x 18,542,855 ops/sec ±0.43% (68 runs sampled)
✓ fast.indexOf() x 26,426,756 ops/sec ±0.32% (61 runs sampled)
✓ fast.indexOf() v0.0.2 x 51,836,531 ops/sec ±0.42% (68 runs sampled)
✓ underscore.indexOf() x 454,750 ops/sec ±0.20% (69 runs sampled)
✓ lodash.indexOf() x 30,030,658 ops/sec ±0.56% (65 runs sampled)

Result: fast.js is 42.52% faster than Array::indexOf().

Native .indexOf() vs fast.indexOf() (1000 items)
✓ Array::indexOf() x 425,244 ops/sec ±0.15% (69 runs sampled)
✓ fast.indexOf() x 668,371 ops/sec ±0.58% (50 runs sampled)
✓ fast.indexOf() v0.0.2 x 863,904 ops/sec ±0.58% (68 runs sampled)
✓ underscore.indexOf() x 34,999 ops/sec ±0.17% (68 runs sampled)
✓ lodash.indexOf() x 929,767 ops/sec ±0.58% (69 runs sampled)

Result: fast.js is 57.17% faster than Array::indexOf().

Native .lastIndexOf() vs fast.lastIndexOf() (3 items)
✓ Array::lastIndexOf() x 59,217,401 ops/sec ±0.26% (68 runs sampled)
✓ fast.lastIndexOf() x 89,634,656 ops/sec ±0.22% (68 runs sampled)
✓ fast.lastIndexOf() v0.0.2 x 520,439,848 ops/sec ±0.84% (67 runs sampled)
✓ underscore.lastIndexOf() x 36,817,740 ops/sec ±0.30% (69 runs sampled)
✓ lodash.lastIndexOf() x 76,479,152 ops/sec ±0.56% (69 runs sampled)

Result: fast.js is 51.37% faster than Array::lastIndexOf().

Native .lastIndexOf() vs fast.lastIndexOf() (10 items)
✓ Array::lastIndexOf() x 29,855,471 ops/sec ±0.93% (69 runs sampled)
✓ fast.lastIndexOf() x 42,600,442 ops/sec ±0.40% (67 runs sampled)
✓ fast.lastIndexOf() v0.0.2 x 116,518,995 ops/sec ±1.38% (62 runs sampled)
✓ underscore.lastIndexOf() x 18,740,830 ops/sec ±0.36% (69 runs sampled)
✓ lodash.lastIndexOf() x 35,528,981 ops/sec ±0.35% (69 runs sampled)

Result: fast.js is 42.69% faster than Array::lastIndexOf().

Native .lastIndexOf() vs fast.lastIndexOf() (1000 items)
✓ Array::lastIndexOf() x 2,284,369 ops/sec ±0.23% (70 runs sampled)
✓ fast.lastIndexOf() x 2,342,871 ops/sec ±0.24% (70 runs sampled)
✓ fast.lastIndexOf() v0.0.2 x 2,361,572 ops/sec ±1.44% (67 runs sampled)
✓ underscore.lastIndexOf() x 2,173,252 ops/sec ±0.28% (69 runs sampled)
✓ lodash.lastIndexOf() x 1,359,633 ops/sec ±0.45% (70 runs sampled)

Result: fast.js is 2.56% faster than Array::lastIndexOf().

```