Passing tuples

Benchmark created on


Description

Yea...

Setup

function inArgsOutArr(a, b){
	return [a,b];
}
function inArgsOutObj(a, b){
	return {a, b};
}
function inArrOutArr([a, b]){
	return [a,b];
}
function inArrOutObj([a, b]){
	return {a, b};
}
function inObjOutArr({a, b}){
	return [a, b];
}
function inObjOutObj({a, b}){
	return {a, b};
}
function inArrOutArrD(arr){
	const [a, b] = arr;
	return [a, b];
}
function inArrOutObjD(arr){
	const [a, b] = arr;
	return {a, b};
}
function inArr2OutArrD(arr){
	const {0:a, 1:b} = arr;
	return [a, b];
}
function inArr2OutObjD(arr){
	const {0: a, 1:b} = arr;
	return {a, b};
}
function inObjOutArrD(obj){
	const {a, b} = obj;
	return [a, b];
}
function inObjOutObjD(obj){
	const {a, b} = obj
	return {a, b};
}

Teardown


Test runner

Ready to run.

Testing in
TestOps/sec
In separate arguments, out array
const a = Math.random();
const b = Math.random();
const result = inArgsOutArr(a, b);
ready
In separate arguments, out object
const a = Math.random();
const b = Math.random();
const result = inArgsOutObj(a, b);
ready
In array (destruct in args), out array
const a = Math.random();
const b = Math.random();
const result = inArrOutArr([a, b]);
ready
In array (destruct in args), out array
const a = Math.random();
const b = Math.random();
const result = inArrOutObj([a, b]);
ready
In object (destruct in args), out array
const a = Math.random();
const b = Math.random();
const result = inObjOutArr({a, b});
ready
In object (destruct in args), out array
const a = Math.random();
const b = Math.random();
const result = inObjOutObj({a, b});
ready
In array (destruct in body), out array
const a = Math.random();
const b = Math.random();
const result = inArrOutArrD([a, b]);
ready
In array (destruct in body), out object
const a = Math.random();
const b = Math.random();
const result = inArrOutObjD([a, b]);
ready
In array (destruct in body as object), out array
const a = Math.random();
const b = Math.random();
const result = inArr2OutArrD([a, b]);
ready
In array (destruct in body as object), out object
const a = Math.random();
const b = Math.random();
const result = inArr2OutObjD([a, b]);
ready
In object (destruct in body), out array
const a = Math.random();
const b = Math.random();
const result = inObjOutArrD({a, b});
ready
In object (destruct in body), out object
const a = Math.random();
const b = Math.random();
const result = inObjOutObjD({a, b});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.