or vs. plus

new topic     » topic index » view thread      » older message » newer message

-- shouldn't these have identical results?
-- if not, there's an optimization to be had, right?

include get.e

atom timer, c1, c2, x

c1=0
c2=0

puts(1,"Timing 'or' vs. '+'\n\n")

puts(1,"or: ")
timer = time() + 3
while timer > time() do
	x = 475938 or 837298
	c1 += 1
end while
?c1

puts(1,"+ : ")
timer = time() + 3
while timer > time() do
	x = 475938 + 837298
	c2 += 1
end while
?c2

if c2 > c1 then
	printf(1,"\n'+' is %.03f times faster!",{c2/c1})
else
	printf(1,"\n'or' is %f.2 times faster!",{c1/c2})
end if

if wait_key() then end if



-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu