Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use spread syntax to make fromCallback faster #12

Merged
merged 1 commit into from
Jul 16, 2020

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.

None yet

2 participants