存档

文章标签 ‘erlang’

erlang网络编程的几个性能调优和注意点

2009年10月25日 没有评论

前些天给echo_server写了个非常简单的连接压力测试程序,

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-module(stress_test).   
 
-export([start/0, tests/1]).   
 
start() ->   
    tests(12345).   
 
tests(Port) ->   
    io:format("starting~n"),   
    spawn(fun() -> test(Port) end),   
    spawn(fun() -> test(Port) end),   
    spawn(fun() -> test(Port) end),   
    spawn(fun() -> test(Port) end).   
 
test(Port) ->   
     case gen_tcp:connect("192.168.0.217", Port, [binary,{packet, 0}]) of   
    {ok, _} ->   
            test(Port);   
    _ ->   
        test(Port)   
    end.

阅读全文…

鞋衫各式名品专卖

收藏与分享
分类: erlang, 云计算 标签: , , ,