console.time shows different time running the same function

ε祈祈猫儿з 提交于 2019-12-06 12:12:59

To quote the answer in the the following link:

If you run shorten multiple times, the V8 engine has a JIT compiler that will optimize that piece of code so it runs faster the next time.

https://stackoverflow.com/a/54601440

Try changing the argument value, for example

console.time('1')
findIP('1,2,3,4,5,6,7,8,9,0')
console.timeEnd('1')
console.time('2')
findIP('1,2,3,4,43,6,7,8,9,4')
console.timeEnd('2')

you will see approx equal time

Reason of that difference is: The browser cache

Simple Definition browser cache is a temporary storage area in memory or on disk that holds the most recently downloaded Web pages and/or calculated result.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!