Is there an inbuild method in JavaScript for calculating time complexity of algorithms?
For instance, if I feed in this function:
function solution(A) {
let smallestInt = 1;
function existsInArray(val) {
return A.find((a) => a === val);
}
for (let index = smallestInt; index < 1000000; index++) {
if (existsInArray(index) && !existsInArray(index + 1) &&
existsInArray(smallestInt)) {
smallestInt = index + 1
}
}
return smallestInt;
}
The method should be able to tell me that the time complexity of the algorithm is O(N*2) or whichever correct answer would be?
If no inbuild method is available, is there a library with automated methods for achieving this?