Apr 22

c,golang,java,php,nodejs,python,pypy运算速度粗焅比较 不指定

bkkkd , 23:40 , 开发应用 , 评论(0) , 引用(0) , 阅读(2378) , Via 本站原创 | |
先把结果抛出来,

run java:
end i:1000000000 count:499999999500000000 time:0.638
run C:
end i:1000000000 count 499999999500000000 time:0.641424
run go:
end i:1000000000 count:499999999500000000 time:1.277728
run pypy:
end i:1000000000 count:499999999500000000 time:3.81583285332
run php
end i:1000000000 count:499999999500000000 time:26.515455007553
run nodejs:
end i:1000000000 count:499999999500000000 time:148.331
run python:
^Tend i:1000000000 count:499999999500000000 time:193.98550415

以上的结果进行了golang和c的性能优化.



这个结果是超出了我的预期的.

1,c和golang都没有启动优化,所以性能只是算是中间位置.作为参考时间
2,java,nodejs和pypy,使用了JIT的都能运算的很快.(和目前这个测试算法有关,但确实明显对重复运算是有帮助)
3,静态语言和动态语言的运营速度没有明显的差异,重点是有没有JIT
4,python实在是太慢了,一直都知道python慢,但没有想到在运算方面会比php慢.
5,nodejs在大数处理未如理想.如果不使用BigInt确实比php,python,pypy都要快.

ps:
1.最终期待php8,因为php8带有jit.
2.php确实错过了更好的发展.在2011年的时候如果接受了HHVM,也许不一个状态了.世事就是这样,在你最火的时候,后面就是开始走下坡.只有不段变更才会处于不败之地.

测试代码:
https://gitee.com/goodtim/LangTest



未对golang和c进行优化的结果,nodejs未采用BigInt处理:

run C:
end i:1000000000 count 499999999500000000 time:5.403450
run go:
end i:1000000000 count:499999999500000000 time:4.085926
run nodejs:
end i:1000000000 count:499999999067109000 time:2.568
run java:
end i:1000000000 count:499999999500000000 time:1.281
run php
end i:1000000000 count:499999999500000000 time:27.162304878235
run python:
end i:1000000000 count:499999999500000000 time:200.668512821
run pypy:
end i:1000000000 count:499999999500000000 time:3.82159590721

发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]