进程消息发送与接收
1> test:test_proc_msg(10000000, {"test"}).
{3145000,ok}
2> test:test_proc_msg(10000000, {"test","test"}).
{3731000,ok}
3> test:test_proc_msg(10000000, {"testtesttesttest"}).
{4428000,ok}
4> test:test_proc_msg(10000000, {"testtest"}).
{3607000,ok}
5> test:test_proc_msg(10000000, {"test"}).
{3237000,ok}
1000W条简单消息发送接收时间3~4秒,每秒可以处理200W的消息,消息的大小对速度影响比较大
ets查询性能
3> test:test_ets(10000000, "test").
{
{insert,{17341000,ok}},{lookup,{1717000,ok}}}
1000W万次ets写入花了17.3S,平均57W/S
1000W万次ets查询花了1.7S,平均580W/S,约为写入时间的十分之一
-module(test).
-compile(export_all).
-define(TAB, tab_name).
%%测试ets查询性能
test_ets(Num, Msg) ->
ets:new(?TAB, [named_table,public]),
InsertCostTime = timer:tc(?MODULE,inser

本文展示了Erlang中进程间消息传递(如{'test','test'})的性能测试,1000万个消息的发送接收耗时在3到4秒之间,表明每秒可处理约200万个消息,且消息大小显著影响速度。另外,对ETS(Erlang Term Storage)进行了1000万个条目的写入和查询性能测试,写入耗时约17.3秒,平均写入速度为57万条/秒,而查询仅用1.7秒,平均查询速度高达580万条/秒,查询速度是写入的约十分之一。
最低0.47元/天 解锁文章
6720

被折叠的 条评论
为什么被折叠?



