带ETS的Erlang-ring基准测试

带ETS的Erlang-ring基准测试,erlang,ets,Erlang,Ets,我正在尝试编写一个环基准测试,其中我有N个进程,通过它们发送消息m次。我想将进程的pid存储在ETS表中 -module(ringmets). -compile(export_all). start_m(N, M, Msg) -> ets:new(pid, [ordered_set, named_table]), List = start_proc(N, M), %tv:start(), [ets:insert(pid, {Pid, X}) || {Pi

我正在尝试编写一个环基准测试,其中我有N个进程,通过它们发送消息m次。我想将进程的pid存储在ETS表中

-module(ringmets).

-compile(export_all).

start_m(N, M, Msg) ->
    ets:new(pid, [ordered_set, named_table]),
    List = start_proc(N, M),
    %tv:start(),
    [ets:insert(pid, {Pid, X}) || {Pid,X} <- lists:zip(lists:seq(1,N), List)],
    hd(List) ! {Msg, 1}.

start_proc(0, _M) ->
    [];
start_proc(N, M) ->
    [spawn(ring_m, loop, [M, N]) | start_proc(N-1, M)].

loop(-1, _N) ->
    ok;
loop(M, N) ->
    receive
        {Msg, CurrPid} ->
        case CurrPid == N of
            true -> Next = 1;
            false -> Next = CurrPid + 1
        end,
        LU = ets:lookup(pid, Next),
        NextPid = element(2, hd(LU)),
        NextPid ! {Msg, Next},
        loop(M-1, N)
    end.
-模块(ringmets)。
-编译(全部导出)。
开始\u m(N,m,Msg)->
ets:新的(pid,[有序集合,命名表格],
列表=启动程序(N,M),
%电视:开始(),
[ets:插入(pid,{pid,X})|{pid,X}
[];
启动程序(N,M)->
[spawn(环[m,循环[m,N])|开始[u过程(N-1,m)]。
循环(-1,N)->
好啊
循环(M,N)->
接收
{Msg,CurrPid}->
案例CurrPid==N个,共个
true->Next=1;
false->Next=CurrPid+1
完,,
LU=ets:查找(pid,下一步),
NextPid=元素(2,hd(LU)),
NextPid!{Msg,Next},
回路(M-1,N)
结束。
电话:

2>铃声:开始(5,5,正常)。
{好的,1}
3>
=错误报告===2012年11月22日::19:51:43===
进程中存在错误,退出值为:{unde,[{ring_m,loop,[5,5]}}
=错误报告===2012年11月22日::19:51:43===
进程中存在错误,退出值为:{unde,[{ring_m,loop,[5,1]}}
=错误报告===2012年11月22日::19:51:43===
进程中存在错误,退出值为:{unde,[{ring_m,loop,[5,4]}}
=错误报告===2012年11月22日::19:51:43===
进程中存在错误,退出值为:{unde,[{ring_m,loop,[5,2]}}
=错误报告===2012年11月22日::19:51:43===
退出值为{unde,[{ring_m,loop,[5,3]}的进程出错

loop/2已导出,因此我不明白为什么会出现此错误。

您的模块是ringmets,而不是ring\m

谢谢,我没有意识到。
2> ringmets:start_m(5,5,ok).
{ok,1}
3>
=ERROR REPORT==== 22-Nov-2012::19:51:43 ===
Error in process <0.38.0> with exit value: {undef,[{ring_m,loop,[5,5]}]}


=ERROR REPORT==== 22-Nov-2012::19:51:43 ===
Error in process <0.42.0> with exit value: {undef,[{ring_m,loop,[5,1]}]}


=ERROR REPORT==== 22-Nov-2012::19:51:43 ===
Error in process <0.39.0> with exit value: {undef,[{ring_m,loop,[5,4]}]}


=ERROR REPORT==== 22-Nov-2012::19:51:43 ===
Error in process <0.41.0> with exit value: {undef,[{ring_m,loop,[5,2]}]}


=ERROR REPORT==== 22-Nov-2012::19:51:43 ===
Error in process <0.40.0> with exit value: {undef,[{ring_m,loop,[5,3]}]}