Skip to content

Conversation

joepie91
Copy link
Contributor

Selection_999(394)

"use strict";

const benchmark = require("benchmark");

let suite = new benchmark.Suite();

function someFunc(one, two, three) {
	return one + two + three;
}

function usingConcat(... args) {
	return someFunc.apply(this, args.concat([ 3 ]))
}

function usingRestCall(... args) {
	return someFunc.call(this, ... args, 3);
}

function usingRest(... args) {
	return someFunc(... args, 3);
}

suite
	.add("concat + apply", () => {
		usingConcat(1, 2);
	})
	.add("rest + call", () => {
		usingRestCall(1, 2);
	})
	.add("rest", () => {
		usingRest(1, 2);
	})
	.on("cycle", (event) => {
		console.log(String(event.target));
	})
	.on("complete", function () {
		console.log('Fastest is ' + this.filter('fastest').map('name'));
	})
	.run({
		async: true
	});

@RyanZim RyanZim merged commit 5b2eb5d into RyanZim:master Jul 16, 2020
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.

2 participants