We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://jsperf.com/calc-compare-twice/ 这一份是对比了两次while循环的substr,发现我的单次while循环基本上比它慢一点
https://jsperf.com/calc-compare-bit/ 这一份是对比按位操作的,基本上单次循环的substr比它快
我的方法基本上处于两者之间,为保证测试结果测试用例参考的是issue中的,想请问一下老师,我的写法是否有改进的地方 ps:不知道为何我的jsperf无法添加snippet,没有那个按钮=。=
The text was updated successfully, but these errors were encountered:
const myadd = (x, y) => { let sum=[], res=0, lenMax=0, rs, X, Y, Xlen, Ylen, rsLen; while (x.length > 0 || y.length > 0) { X=x.substr(-14); Y=y.substr(-14); Xlen=X.length, Ylen=Y.length; rs=String(Number(X)+Number(Y)+res); lenMax=Math.max(Xlen,Ylen); rsLen=rs.length; if(rsLen>lenMax){ rs=rs.substr(1,rsLen-1); res=1; }else{ res=0; } x = x.substr(0, x.length - 14); y = y.substr(0, y.length - 14); sum.unshift(rs) } res==1&&sum.unshift(res) return sum.join(''); }
附上我的代码
Sorry, something went wrong.
No branches or pull requests
https://jsperf.com/calc-compare-twice/
这一份是对比了两次while循环的substr,发现我的单次while循环基本上比它慢一点
https://jsperf.com/calc-compare-bit/
这一份是对比按位操作的,基本上单次循环的substr比它快
我的方法基本上处于两者之间,为保证测试结果测试用例参考的是issue中的,想请问一下老师,我的写法是否有改进的地方
ps:不知道为何我的jsperf无法添加snippet,没有那个按钮=。=
The text was updated successfully, but these errors were encountered: