一段普通的冒泡排序(N=1000,耗时约2秒)
https://gist.github.com/mutoo/5675436/9a3f49888f06d2de7450ddbf269696184d6353da
把冒泡放到function里面,奇迹发生了,(N=1000,耗时不到200毫秒)
https://gist.github.com/mutoo/5675436/2b15c4b2eb783d51e32f0a5b9f72c1bf5f17ca79
这是为什么呢?
测试环境 mac osx 10.8/chrome 27
https://gist.github.com/mutoo/5675436/9a3f49888f06d2de7450ddbf269696184d6353da
把冒泡放到function里面,奇迹发生了,(N=1000,耗时不到200毫秒)
https://gist.github.com/mutoo/5675436/2b15c4b2eb783d51e32f0a5b9f72c1bf5f17ca79
这是为什么呢?
测试环境 mac osx 10.8/chrome 27