[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: single quotes vs. double quotes
- From: Ico <lua@...>
- Date: Mon, 12 Oct 2009 15:32:57 +0200
> In most languages (not only scripting) the use of single quotes is faster
> than double quotes, does it is applicable in Lua? perhaps for the other ways
> define strings?
When in doubt, just test.
code = {
double = [[ a = "test 1234\n" ]],
single = [[ a = 'test 1234\n' ]],
long = [=[ a = [[test 1234\n]] ]=]
}
for type, line in pairs(code) do
t1 = os.time()
while t1 == os.time() do end
t1 = t1 + 1
count = 0
while t1 == os.time() do
chunk = loadstring(line)
chunk()
count = count + 1
end
print(type, count)
end
(bad example because of the os.time() overhead in each loop, but sure to
complete in a few seconds)
Result on my intel 2.2Ghz show no sigificant difference:
double 257167
long 251103
single 254788
--
:wq
^X^Cy^K^X^C^C^C^C