esrrhs / fake Goto Github PK
View Code? Open in Web Editor NEW嵌入式脚本语言 Lightweight embedded scripting language
License: MIT License
嵌入式脚本语言 Lightweight embedded scripting language
License: MIT License
vm的关键在gc呀。小代码测试不出gc问题,业务复杂点gc就关键了,请问贵脚本gc是何方法?
如题,另外开启部分 JIT 后性能大概能提升多少呢?
多谢 :-)
此前在网上看到系列脚本的测试脚本,拿斐波那契数列的脚来看:
Lua:
function fibR(n)
if (n < 2) then return n end
return (fibR(n-2) + fibR(n-1))
end
function fibI(n)
local last = 0
local cur = 1
n = n - 1
while (n > 0)
do
n = n - 1
local tmp = cur
cur = last + cur
last = tmp
end
return cur
end
改用fake重写之后:
func fibR(n)
if (n < 2) then return n end
return (fibR(n - 2) + fibR(n - 1))
end
func fibI(n)
var last = 0
var cur = 1
n = n - 1
while (n > 0)
then
n = n - 1
var tmp = cur
cur = last + cur
last = tmp
end
return cur
end
func main()
var N = 43
print("fib: " .. fibR(N) .. " = " , fibI(N))
end
流程一样,在我i9-8950HK CPU,32GB内存的64位Linux环境下,lua要跑55秒,fake半小时都不见返回
我写一个递归函数:
func fibR(n)
if (n<2) then
return n
end
return fibR(n-2)+fibR(n-1)
end
在return fibR(n-2)+fibR(n-1)报错了,无奈,我定义两个变量
1: arg1 := n-1
arg2 := n-2
2: var arg1 = n-1, arg2 = n-2
3: var arg1,arg2
arg1 = n-1
arg2 = n-2
横竖都不对
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.