What is faster?
n = 35
-- is
d = tostring(n)
-- or
c = n .. ""
-- better?
What is faster?
n = 35
-- is
d = tostring(n)
-- or
c = n .. ""
-- better?
Test it yourself. That’s the only way to find out
c=n…" " is faster. I don’t know that for sure, but I have a 60/40 chance I’m right. You’ll have to prove me wrong.
EDIT: Make that 100/0 that I’m right, but I’ll still leave it to you to try and prove me wrong.
But how to see miliseconds change?
displayMode(FULLSCREEN)
function setup()
textMode(CORNER)
font("Courier")
fill(255)
n=35
delay=1000000
end
function draw()
background(0)
text(delay.." iterations each",20,HEIGHT-150)
t=os.clock()
for z=1,delay do
c=tostring(n)
end
d1=os.clock()-t
text("c=tostring(n) "..d1,20,HEIGHT-200)
t=os.clock()
for z=1,delay do
c=n..""
end
d2=os.clock()-t
text('c=n.."" '..d2,20,HEIGHT-230)
text('c=n.."" is '..d1/d2.." times faster than c=tostring(n)",20,HEIGHT-300 )
end