2 var sliced = require('./')
3 var Bench = require('benchmark');
4 var s = new Bench.Suite;
7 s.add('Array.prototype.slice.call', function () {
8 Array.prototype.slice.call(arguments);
9 }).add('[].slice.call', function () {
10 [].slice.call(arguments);
11 }).add('cached slice.call', function () {
13 }).add('sliced', function () {
15 }).on('cycle', function (evt) {
16 console.log(String(evt.target));
17 }).on('complete', function () {
18 console.log('fastest is %s', this.filter('fastest').pluck('name'));
22 var s = new Bench.Suite;
23 s.add('Array.prototype.slice.call(arguments, 1)', function () {
24 Array.prototype.slice.call(arguments, 1);
25 }).add('[].slice.call(arguments, 1)', function () {
26 [].slice.call(arguments, 1);
27 }).add('cached slice.call(arguments, 1)', function () {
28 slice.call(arguments, 1)
29 }).add('sliced(arguments, 1)', function () {
31 }).on('cycle', function (evt) {
32 console.log(String(evt.target));
33 }).on('complete', function () {
34 console.log('fastest is %s', this.filter('fastest').pluck('name'));
38 var s = new Bench.Suite;
39 s.add('Array.prototype.slice.call(arguments, -1)', function () {
40 Array.prototype.slice.call(arguments, -1);
41 }).add('[].slice.call(arguments, -1)', function () {
42 [].slice.call(arguments, -1);
43 }).add('cached slice.call(arguments, -1)', function () {
44 slice.call(arguments, -1)
45 }).add('sliced(arguments, -1)', function () {
47 }).on('cycle', function (evt) {
48 console.log(String(evt.target));
49 }).on('complete', function () {
50 console.log('fastest is %s', this.filter('fastest').pluck('name'));
54 var s = new Bench.Suite;
55 s.add('Array.prototype.slice.call(arguments, -2, -10)', function () {
56 Array.prototype.slice.call(arguments, -2, -10);
57 }).add('[].slice.call(arguments, -2, -10)', function () {
58 [].slice.call(arguments, -2, -10);
59 }).add('cached slice.call(arguments, -2, -10)', function () {
60 slice.call(arguments, -2, -10)
61 }).add('sliced(arguments, -2, -10)', function () {
62 sliced(arguments, -2, -10)
63 }).on('cycle', function (evt) {
64 console.log(String(evt.target));
65 }).on('complete', function () {
66 console.log('fastest is %s', this.filter('fastest').pluck('name'));
70 var s = new Bench.Suite;
71 s.add('Array.prototype.slice.call(arguments, -2, -1)', function () {
72 Array.prototype.slice.call(arguments, -2, -1);
73 }).add('[].slice.call(arguments, -2, -1)', function () {
74 [].slice.call(arguments, -2, -1);
75 }).add('cached slice.call(arguments, -2, -1)', function () {
76 slice.call(arguments, -2, -1)
77 }).add('sliced(arguments, -2, -1)', function () {
78 sliced(arguments, -2, -1)
79 }).on('cycle', function (evt) {
80 console.log(String(evt.target));
81 }).on('complete', function () {
82 console.log('fastest is %s', this.filter('fastest').pluck('name'));
89 * Array.prototype.slice.call x 1,289,592 ops/sec ±2.88% (87 runs sampled)
90 * [].slice.call x 1,345,451 ops/sec ±1.68% (97 runs sampled)
91 * cached slice.call x 10,719,886 ops/sec ±1.04% (99 runs sampled)
92 * sliced x 15,809,545 ops/sec ±1.46% (93 runs sampled)