gopher-lua初步了解

最近看到golang里面有人实现了一套lua的调用库。
go-lua
https://github.com/yuin/gopher-lua
github.com/aarzilli/golua/lua

性能对比
This exercises the call stack implementation. When computing fib(35), go-lua is about 6x slower than the C Lua interpreter. Gopher-lua is about 20% faster than go-lua. Much of the performance difference between go-lua and gopher-lua comes from the inclusion of debug hooks in go-lua. The remainder is due to the call stack implementation - go-lua heap-allocates Lua stack frames with a separately allocated variant struct, as outlined above. Although it caches recently used stack frames, it is outperformed by the simpler statically allocated call stacks in gopher-lua.

  $ time lua fibr.lua
  real  0m2.807s
  user  0m2.795s
  sys   0m0.006s

  $ time glua fibr.lua
  real  0m14.528s
  user  0m14.513s
  sys   0m0.031s

  $ time go-lua fibr.lua
  real  0m17.411s
  user  0m17.514s
  sys   0m1.287s

这套方案,是使用golang完整编写了一套lua vm,性能非常差。而且这套东西是不能兼容使用C语言编写的三方库lua库,打比方就是protobuf-c的库就无法使用。其实这样就局限了这套代码的用途了。如果是使用来编写一些简单的逻辑,是可以的。做做配置也是不错,但是其他的事情,这个是不合适的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值