获得徽章 0
赞了这篇沸点
新文章:“CSS scroll-target-group加:target-current滚动菜单自动高亮” -
www.zhangxinxu.com CSS野心太大了,那种页面滚动,标题导航自动高亮匹配的效果现在也能纯CSS实现了。
1
3
我发现了一个 js 通过分支预测,达到性能优化的方案,但是效果好像不是很好,我也现在好像也不太会写博客了,写不出来了,感觉性能优化的也逊色一点。不过应该所有语言都可以这样写,不过我之前没遇到过忘了在哪里遇到了一篇文章讲了这样的内容,分支预测相关的
node ./index.js
当前数据量: 100000000
使用 if 分支预测预处理 x 0.83 ops/sec ±1.45% (7 runs sampled)
纯 map 处理 x 0.62 ops/sec ±0.91% (6 runs sampled)
测试结果:
使用 if 分支预测预处理: 平均执行时间 1209422.3 μs
使用 if 分支预测预处理: 平均执行时间 1.209 ms
纯 map 处理: 平均执行时间 1625934.0 μs
纯 map 处理: 平均执行时间 1.626 ms
最快的是:使用 if 分支预测预处理
code.juejin.cn
node ./index.js
当前数据量: 100000000
使用 if 分支预测预处理 x 0.83 ops/sec ±1.45% (7 runs sampled)
纯 map 处理 x 0.62 ops/sec ±0.91% (6 runs sampled)
测试结果:
使用 if 分支预测预处理: 平均执行时间 1209422.3 μs
使用 if 分支预测预处理: 平均执行时间 1.209 ms
纯 map 处理: 平均执行时间 1625934.0 μs
纯 map 处理: 平均执行时间 1.626 ms
最快的是:使用 if 分支预测预处理
展开
评论
点赞
![[快哭了]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_47.63391a1.png)
![[无辜呆]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_96.4fb9d71.png)
招聘
开源
Linux
GitHub