- 浏览: 27028 次
- 性别:
- 来自: 广州
最新评论
fun这么好用。为什么老大在最近都说不要用?
这2个有什么区别?为什么要改?
fun() ->end
erlang efficiency guide第一个原则就是说:
本地调用>=跨模块调用> fun() ->apply/3
http://www.erlang.org/doc/efficiency_guide/myths.html#id61433
http://www.cnblogs.com/me-sa/archive/2012/05/06/erlang-function-call-efficiency.html
当然由于版本的更新,效率差距估计不会这么大。但是
本地调用>=跨模块调用> fun() ->apply/3 这个是确定的。
所以最近游戏在优化广播发包时把广播由fun() ->end 改为Mod:Fun(Arg)是非常好一种尝试。
gen:call(PID,{func,fun() ->broadcast_to_whole_map(Record) end}). handle_call({func,F},_From,State) -> Reply = F(), {reply, Reply, State}.
gen:call(PID,{server_module,broadcast_to_whole_map,[Record]}). handle_call({server_module,broadcast_to_whole_map,[Record]},_From,State) -> Reply = server_module:broadcast_to_whole_map(Record) , {reply,Reply,State}.
这2个有什么区别?为什么要改?
fun() ->end
erlang efficiency guide第一个原则就是说:
本地调用>=跨模块调用> fun() ->apply/3
http://www.erlang.org/doc/efficiency_guide/myths.html#id61433
引用
2.1 Myth: Funs are slowYes, funs used to be slow. Very slow. Slower than apply/3. Originally, funs were implemented using nothing more than compiler trickery, ordinary tuples, apply/3, and a great deal of ingenuity.
But that is ancient history. Funs was given its own data type in the R6B release and was further optimized in the R7B release. Now the cost for a fun call falls roughly between the cost for a call to local function and apply/3.
But that is ancient history. Funs was given its own data type in the R6B release and was further optimized in the R7B release. Now the cost for a fun call falls roughly between the cost for a call to local function and apply/3.
http://www.cnblogs.com/me-sa/archive/2012/05/06/erlang-function-call-efficiency.html
当然由于版本的更新,效率差距估计不会这么大。但是
本地调用>=跨模块调用> fun() ->apply/3 这个是确定的。
所以最近游戏在优化广播发包时把广播由fun() ->end 改为Mod:Fun(Arg)是非常好一种尝试。
发表评论
-
Erlang 简单的节点互连
2014-03-19 23:41 469自己写的游戏跨服初步构架,以后再一点点完善,先记下时间线哈。 ... -
简单erlang节点互连实验
2014-03-10 15:53 680如果erlang:节点test1,test2互连接: 1.节点 ... -
Erlang OTP gen_event (1)
2014-02-26 15:06 1002演示gen_event的运行过程: mod_event_ma ... -
Erlang OTP gen_event (0)
2014-02-26 14:30 1131原英文文档:http://www.erlang.org/erl ... -
erlang efficient guide 3
2013-08-19 22:19 1047* 3 Common Caveats * 3常见 ... -
erlang efficient guide 2
2013-08-18 01:02 8222 The Eight Myths of Erlang Per ... -
emacs 的erlang-flymake
2013-08-14 15:15 1409emacs 设置erlang-flymake erlang- ... -
erlang ets
2013-07-22 23:08 1781参见:http://www.cnblogs.com ... -
erlang的编程规范
2013-03-26 17:17 1873Programming Rules and Conventio ... -
Erlang------Mnesia
2013-03-25 12:49 1650读erlang编程指南Mnesia笔记: 1.mnesia 是 ... -
进程环
2013-03-18 16:48 771编写一个程序,它生成N ... -
匿名函数fun
2012-12-15 16:12 760lists:map(fun/1,[1,2,3]). 小试匿名函 ... -
并发编程实战otp--open telecom platform 二
2012-10-10 23:17 1098第二章:Erlang语言精要。 shell 的启动参数h ... -
并发编程实战otp--open telecom platform 一
2012-10-10 23:16 11401.erlang 的进程模型: 并发的基本单位是进程, ... -
learn some erlang
2012-10-09 22:54 667Erlang has this very pragm ... -
erlang语句块的简洁使用
2012-09-25 22:48 624begin end语句块的简洁使用:问题描述:将一堆人 ... -
命令式编程语言的标杆
2012-09-25 09:47 636命令式编程语言的标杆: 1.进程必须是语言的核心; 2.任何进 ... -
emacs与erlang的完美结合
2012-09-23 22:48 12271.在emacs中使用c+x c+z 启动erlang she ...
相关推荐
fun转fun转fun转换fun转换fun转换fun转换fun转换fun转换fun转换fun转换
是路径规划的实用方法,包括随机梯度算法,相对梯度算法,包括轨道机动仿真、初轨计算。
FUN3d,非结构求解器的编译过程,非常详细,包括后处理等
Coding4Fun控件库,包括一些Windows phone控件
转账Fun with Joe and Bob
5uonly_fun.apk
fun noughts and crosses game (tic tac toe)
BPSK CODE have fun everyone
函数fun的功能是进行数字字符转换,若形参ch中是数字字符‘0’~‘9’,则‘0’转换为‘9’,‘1’转换成‘8’,‘2’转换成‘7’,… …,‘9’转换成‘0’,若是其它字符则保持不变:并将转换后的结果作为函数值...
Docker for Fun and Profit
Coding4Fun WP开发
一种基本的粒子群优化算法,待寻优的目标函数为fun函数
在main函数中调用函数fun(int[] a, int m),(其中m是在main中用键盘输入的小于100的整数),用fun 函数找出大于整数m,并且邻接m的5个素数,将这5个素数,用a数组接收,并在main中输出;(请根据题 目完成main和...
该函数返回值为积分结果,形参a,b分别为积分上下限,fun是被积函数。该函数用来求积分值。
etl pictor is not used please to test this upload fun
National Semiconductor LP3944 Fun-light Chip.
tap4fun游戏竞赛数据,很全的数据,可用来训练模型,比赛
Web安全论资料 sH:Having Fun with XML Hacking
请编写函数fun,它的功能是:求出1到100之内能北7或者11整除,但不能同时北7和11整除的所有证书,并将他们放在a所指的数组中,通过n返回这些数的个数。
信息隐藏技术实验教程中diamondreplace.m的子涵数replace32fun.m