YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

squirrel 3.1's speed is faster
renshijun
#1 Posted : Tuesday, January 3, 2017 12:04:47 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 12/26/2014(UTC)
Posts: 30
Location: Harbin, China

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
As the title says, it's faster than lua(not luajit).
dane
#2 Posted : Sunday, January 15, 2017 8:46:55 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/15/2017(UTC)
Posts: 1
Location: dane

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
It would be favorable that you post some evidence to back up your claim.

I ran a small test of my own using Lua 5.3.3 (64 bit) and Squirrel 3.1 (64 bit). Here are the scripts and the outputs:

.nut
Code:

class vec2 {
    x = null;
    y = null;
    
    constructor(x, y) { this.x = x; this.y = y; }
    
    function _mul(other) {return vec2(x * other.x, y * other.y); }
};

local operations = 10000000;
local t = clock();

local a = vec2(1, 1);
local b = vec2(1, 1);

for (local i = 0; i < operations; i++) {
    local c = a * b;
}

t = clock() - t;

println(format("[Squirrel3.1]: Time taken to perform %d operations: %.1fms", operations, t*1000));


.lua
Code:

vec2 = {};

function Vec2(x, y)
    return setmetatable({x = x, y = y}, vec2)
end

function vec2.__mul(lhs, rhs) return Vec2(lhs.x * rhs.x, lhs.y * rhs.y); end
function vec2.__tostring(v) return "(" .. v.x .. ", " .. v.y .. ")" end

local operations = 10000000
local t = os.clock()

local a = Vec2(1, 1)
local b = Vec2(1, 1)

for i = 0, operations do
    local c = a * b
end

t = os.clock() - t;

print(string.format("[Lua 5.3.3]: Time taken to perform %d operations: %.1fms", operations, t*1000));


Code:
C:\Users\Dane\Desktop\lua-5.3.3>lua test.lua && sq test.nut
[Lua 5.3.3]: Time taken to perform 10000000 operations: 5847.0ms
[Squirrel3.1]: Time taken to perform 10000000 operations: 5990.0ms
Kelvin
#3 Posted : Friday, May 5, 2017 9:17:30 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/26/2015(UTC)
Posts: 46
Man
Location: VA

Thanks: 2 times
Was thanked: 0 time(s) in 0 post(s)
Wait, Lua can run Squirrel, too?
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.103 seconds.