|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
What is actually easier for POV to parse,
(Float_Value*2) or (Float_Value+Float_Value)?
Does it make a difference? I tend to recall that
I've learned somewhere that any parser/CPU has
to do some extra job to break down the "multiply with
2" into something it can actually calculate, while
"add" is very simple and clean to do for a CPU.
Am I correct?
--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Tim Nikias <tim### [at] gmxde> wrote:
> What is actually easier for POV to parse,
> (Float_Value*2) or (Float_Value+Float_Value)?
I don't think there's any difference.
In fact, I think that the former could be faster because a short constant
is probably faster to parse than a long identifier name (with the proper
value lookup involved).
> Does it make a difference? I tend to recall that
> I've learned somewhere that any parser/CPU has
> to do some extra job to break down the "multiply with
> 2" into something it can actually calculate, while
> "add" is very simple and clean to do for a CPU.
You have probably confused something else with this. There's no practical
difference between addition and multiplication.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp <war### [at] tagpovrayorg> wrote in news:3d50449e@news.povray.org
> You have probably confused something else with this. There's no
> practical
> difference between addition and multiplication.
and how about optimizing i.e.
x*x*x <--> pow(x,3)
x*y + x*z <--> x*(y+z)
sqrt(ln(pow(x,100))) + sqrt(ln(pow(x,100))) <--> 2*sqrt(ln(pow(x,100)))
etc ?
it would be very good idea to optimize functions in isosurface
--
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3d50350b$1@news.povray.org>,
"Tim Nikias" <tim### [at] gmxde> wrote:
> What is actually easier for POV to parse,
> (Float_Value*2) or (Float_Value+Float_Value)?
>
> Does it make a difference? I tend to recall that
> I've learned somewhere that any parser/CPU has
> to do some extra job to break down the "multiply with
> 2" into something it can actually calculate, while
> "add" is very simple and clean to do for a CPU.
The differences between CPU instructions are so little compared to the
parser overhead that you probably couldn't even measure the difference,
and modern processors are so much more complex that it isn't even worth
thinking about, and modern compilers will automatically optimize many
things...the multiply by 2 might end up faster than an add.
However, for POV: the first version has fewer characters, so the current
parser would probably parse it a little more quickly. If used in a
function, there would be no noticeable difference in how fast the
function executed.
--
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 6 Aug 2002 19:26:00 -0400, "Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote:
> it would be very good idea to optimize functions in isosurface
that's why some optimizations are already implemented
ABX
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3d50449e@news.povray.org...
> Tim Nikias <tim### [at] gmxde> wrote:
> > What is actually easier for POV to parse,
> > (Float_Value*2) or (Float_Value+Float_Value)?
>
> I don't think there's any difference.
> In fact, I think that the former could be faster because a short
constant
> is probably faster to parse than a long identifier name (with the proper
> value lookup involved).
I tried a quick test, I ran through 100,000 iterations of each method in
POV, 10 times each with these results (times include trace time but that
shouldn't affect the relative outcome):
A*2
Average: 12.323s
Median: 12.315s
Max: 12.72s
Min: 11.9s
Std Dev: 0.238097
A+A
Average: 11.380s
Median: 11.395s
Max: 11.57s
Min: 11.17s
Std Dev: 0.116046
I also ran each method once with 1,000,000 iterations (i know, poor sampling
size)
A*2: 93.52s
A+A: 89.00s
It would appear that addition is quicker, but perhaps someone else should do
an independent audit.
My machine: 466MHz, 320MB, WinXP
-tgq
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
TinCanMan <Tin### [at] hotmailcom> wrote:
> A+A
You should try with longer identifier names to see if there's any
difference.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3d514788@news.povray.org>,
"TinCanMan" <Tin### [at] hotmailcom> wrote:
> It would appear that addition is quicker, but perhaps someone else should do
> an independent audit.
> My machine: 466MHz, 320MB, WinXP
Probably something to do with how precedence is handled in the parser.
In your test, you used 1 character identifiers, so both expressions were
the same length. I wonder how much of an effect larger identifiers would
have.
Anyway, it isn't enough of a difference to bother thinking about. If you
want to double a value, I find the N*2 to be clearer and easier to keep
up to date than the N+N version.
--
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3d514788@news.povray.org> , "TinCanMan"
<Tin### [at] hotmailcom> wrote:
> It would appear that addition is quicker, but perhaps someone else should do
> an independent audit.
No, it just happens that the parser checks in a certain order (from a users
point of view, I don't plan to explain how the parser works) and it so
happens that the check for multiplication and addition have to occur if a
specific order to make sure precedence is handled properly. This says
nothing about speed of multiplication or addition...
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|