Re: IF NOTs
- From: Jonah Thomas <jethomas5@xxxxxxxxx>
- Date: Sun, 21 Dec 2008 09:31:22 -0500
rickman <gnuarm@xxxxxxxxx> wrote:
Jonah Thomas <jethom...@xxxxxxxxx> wrote:
Could you perhaps time it on some system? That would settle the
matter for that system.
If you actually got measured results on some system then you'd know
how it worked on that system. That would be more valuable than the
sort of guessing you and I have been doing.
Yes. At the very least it would be instructive to see the true code
generated. A lot of this depends on the compiler efficiency in
generating code. If written in assembly language I have no doubt that
the TRUE case is slower.
I did a quick test on gForth 0.6.2 on a PC and found the true case was
slower in roughly the ratio 8:5. This is small enough that it might be
different on other gForth versions or other PCs.
variable times
100000 times !
: side utime 2>r times @ 0 do dup if else then loop utime 2r> d- d. ;
: side1 utime 2>r times @ 0 do noop loop utime 2r> d- d. ;
: test 0 side 1 side side1 ;
However, in the real world, the difference has got to be minute in the
grand scheme of things in most situations.
With completely empty branches, the do loop took a bit more than half
the time for the false case and a bit less than half the time for the
true case. What you do inside the branches has to be pretty quick for
the timing between true and false cases to matter much. It might make
more difference on a Z80.
.
- Follow-Ups:
- Re: IF NOTs
- From: Mike Hore
- Re: IF NOTs
- From: Marcel Hendrix
- Re: IF NOTs
- References:
- IF NOTs
- From: anders . koburg
- Re: IF NOTs
- From: Ed
- Re: IF NOTs
- From: Reinhold Straub
- Re: IF NOTs
- From: Ed
- Re: IF NOTs
- From: Reinhold Straub
- Re: IF NOTs
- From: rickman
- Re: IF NOTs
- From: Elizabeth D Rather
- Re: IF NOTs
- From: rickman
- Re: IF NOTs
- From: Jonah Thomas
- Re: IF NOTs
- From: rickman
- IF NOTs
- Prev by Date: Re: IF NOTs
- Next by Date: Re: IF NOTs
- Previous by thread: Re: IF NOTs
- Next by thread: Re: IF NOTs
- Index(es):
Relevant Pages
|