const actG = {}
let row = null
let type = null
const test1 = (params) => {
console.log(params);
}
const result = []
result.push({
id: 'A1',
test: 'Test1',
cls: 'asd dd da',
act: (ev) => { actG.a1({ r: row, t: type }, ev) }
})
result.push({
id: 'A2',
test: 'Test2',
cls: 'asd dd da2',
act: (ev) => { actG.a2({ r: row, t: type }, ev) }
})
result.push({
id: 'A3',
test: 'Test3',
cls: 'asd dd da3',
act: (ev) => { actG.a3({ r: row, t: type }, ev) }
})
const result = []
result.push({
id: 'A1',
test: 'Test1',
cls: 'asd dd da',
act: ['a1', { r: row, t: type }]
})
result.push({
id: 'A2',
test: 'Test2',
cls: 'asd dd da2',
act: ['a2', { r: row, t: type }]
})
result.push({
id: 'A3',
test: 'Test3',
cls: 'asd dd da3',
act: ['a3', { r: row, t: type }]
})
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
func | |
array |
Test name | Executions per second |
---|---|
func | 58058596.0 Ops/sec |
array | 27177082.0 Ops/sec |
The benchmark defined in the provided JSON compares two approaches for function invocation in JavaScript: invoking functions directly versus invoking functions through an array reference. The benchmark consists of two test cases, labeled "func" and "array".
Test Case: "func"
actG.a1
, actG.a2
, actG.a3
) are called directly within the act
property of the test cases.{ r: row, t: type }
).Test Case: "array"
act
property using an array format. In this case, the array contains the function name as a string and the parameters as an object.Direct Function Invocation (func)
Array Reference Invocation (array)
Potential Libraries: In this benchmark, there is no specific library used for testing. The functions invoked are part of the acting groups (actG
), which are expected to be defined elsewhere in the code. Libraries often used in conjunction with performance testing could include benchmarking libraries like Benchmark.js or utility libraries for functional programming, but they aren't present in this case.
JavaScript Features: There is no particular advanced JavaScript feature or syntax that is specially tested or highlighted in this benchmark. The benchmark focuses on basic JavaScript function invocation techniques.
...
) or rest parameters can only somewhat affect the performance overhead depending on their usage.In summary, this benchmark effectively demonstrates the performance implications between directly calling functions and leveraging an array for indirect calls. Through this analysis, software engineers can make informed decisions on the best method to use based on their specific use case scenarios.