ConardLi / ConardLi.github.io

ConardLi 写 blog 的地方
https://mp.weixin.qq.com/s?__biz=Mzk0MDMwMzQyOA==&mid=2247493407&idx=1&sn=41b8782a3bdc75b211206b06e1929a58&chksm=c2e11234f5969b22a0d7fd50ec32be9df13e2caeef186b30b5d653836b0725def8ccd58a56cf#rd
1.12k stars 273 forks source link

while循环效率问题 #4

Open lingtoo opened 4 years ago

lingtoo commented 4 years ago

我对clone4的DEMO文件涉及到的WHILE循环的效率表示质疑,本地测试到的结果(node环境):

clone1 在前,clone2在后, 结果:

undefined: 0.167ms
undefined: 0.126ms

将 clone1 跟 clone2 调下位置,即clone2放在前面,结果:

undefined: 0.254ms
undefined: 0.081ms

即所消耗的时间跟调用的先后顺序有关,而不是WHILE循环的优化结果,不知你怎么看?

Canight commented 3 years ago

我对clone4的DEMO文件涉及到的WHILE循环的效率表示质疑,本地测试到的结果(node环境):

clone1 在前,clone2在后, 结果:

undefined: 0.167ms
undefined: 0.126ms

将 clone1 跟 clone2 调下位置,即clone2放在前面,结果:

undefined: 0.254ms
undefined: 0.081ms

即所消耗的时间跟调用的先后顺序有关,而不是WHILE循环的优化结果,不知你怎么看?

https://blog.csdn.net/haochuan9421/article/details/81414532