Update mostPerformant.md
This commit is contained in:
@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
Returns the index of the function in an array of functions which executed the fastest.
|
Returns the index of the function in an array of functions which executed the fastest.
|
||||||
|
|
||||||
Use `Array.map()` to generate an array where each value is the total time taken to execute the function
|
Use `Array.map()` to generate an array where each value is the total time taken to execute the function after `iterations` times. Use the difference in `performance.now()` values before and after to get the total time in milliseconds to a high degree of accuracy.
|
||||||
after `iterations` times. Use the difference in `performance.now()` values before and after to get the total time
|
Use `Math.min()` to find the minimum execution time, and return the index of that shortest time which corresponds to the index of the most performant function.
|
||||||
in milliseconds to a high degree of accuracy.
|
Omit the second argument, `iterations`, to use a default of 10,000 iterations. The more iterations, the more reliable the result but the longer it will take.
|
||||||
Use `Math.min()` to find the minimum execution time, and return the index of that shortest time which
|
|
||||||
corresponds to the index of the most performant function. Omit the second argument, `iterations`, to use a default of 10,000 iterations. The more iterations, the more reliable the result but the longer it will take.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const mostPerformant = (fns, iterations = 10000) => {
|
const mostPerformant = (fns, iterations = 10000) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user