1. What's Faster?

Hello,

What is faster during initialization:



    constant A1=#F

or

    constant A1=15

In other words, does the interpreter read hex numbers
faster then whole decimal integer numbers?
And what about whole numbers between max_integer and #FFFFFFFF ?


Also,

    MySeq[5]=1

or

    MySeq[THE_NUMBER_FIVE]=1


This last one doesnt have to include the time it took
to load the constant THE_NUMBER_FIVE.

In other words, is it faster to read a number typed
within the sequence bracket or is it faster to read
the name of the constant, assuming at least 10 characters
in the constants' name?


Take care for now,
Al

new topic     » topic index » view message » categorize

2. Re: What's Faster?

----- Original Message -----
From: "Al Getz" <Xaxo at aol.com>
To: "EUforum" <EUforum at topica.com>
Subject: What's Faster?


>
>
> Hello,
>
> What is faster during initialization:
>
>
>     constant A1=#F
>
> or
>
>     constant A1=15
>
> In other words, does the interpreter read hex numbers
> faster then whole decimal integer numbers?
> And what about whole numbers between max_integer and #FFFFFFFF ?

If there is any speed differences, it would be measured in microseconds and
as constants only get initialized once in an application, you would not
really be able to detect the difference. In short, it isn't worth the time
to worry about it.

>
> Also,
>
>     MySeq[5]=1
>
> or
>
>     MySeq[THE_NUMBER_FIVE]=1
>
>
> This last one doesnt have to include the time it took
> to load the constant THE_NUMBER_FIVE.
>
> In other words, is it faster to read a number typed
> within the sequence bracket or is it faster to read
> the name of the constant, assuming at least 10 characters
> in the constants' name?

Similar story here too. The speed up for using literals rather than
constants is also measured in microseconds. So unless you are doing this
operation many millions of times over, the loss in readability is not worth
the effort.

--
Derek

new topic     » goto parent     » topic index » view message » categorize

3. Re: What's Faster?

----- Original Message -----
From: "Al Getz" <Xaxo at aol.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: What's Faster?


>
>
> Derek Parnell wrote:
> >
> >
> > ----- Original Message -----
> > From: "Al Getz" <Xaxo at aol.com>
> > To: "EUforum" <EUforum at topica.com>
> > Sent: Sunday, June 15, 2003 2:53 AM
> > Subject: What's Faster?
> >
> >
> > > Hello,
> > >
> > > What is faster during initialization:
> > >
> > >
> > >     constant A1=#F
> > >
> > > or
> > >
> > >     constant A1=15
> > >
> > > In other words, does the interpreter read hex numbers
> > > faster then whole decimal integer numbers?
> > > And what about whole numbers between max_integer and #FFFFFFFF ?
> >
> > If there is any speed differences, it would be measured in microseconds
> > and
> > as constants only get initialized once in an application, you would not
> > really be able to detect the difference. In short, it isn't worth the
> > time
> > to worry about it.
> >
> > >
> > > Also,
> > >
> > >     MySeq[5]=1
> > >
> > > or
> > >
> > >     MySeq[THE_NUMBER_FIVE]=1
> > >
> > >
> > > This last one doesnt have to include the time it took
> > > to load the constant THE_NUMBER_FIVE.
> > >
> > > In other words, is it faster to read a number typed
> > > within the sequence bracket or is it faster to read
> > > the name of the constant, assuming at least 10 characters
> > > in the constants' name?
> >
> > Similar story here too. The speed up for using literals rather than
> > constants is also measured in microseconds. So unless you are doing this
> > operation many millions of times over, the loss in readability is not
> > worth
> > the effort.
> >
> > --
> > Derek
> >
> >
> Hello,
>
> Thanks for the reply, but...
>
> The reason i asked the question:
>
> "What is faster"
>
> is because i wanted to know exactly that;
> 'what is faster'.
>
> Of course i dont mind if there is a slight difference
> when using this ONE time, but, as you could have guessed,
> i want to apply the answer to maybe 50,000 such cases
> in the same program.
>
> In this case:
>
> 50,000 times 10us equals 0.5 second difference in loading time,
> if in fact it is 10us, but if it's 1us THEN it doesnt matter.
> Since i have control over which way to do it, im not going
> to choose the longer time if i can help it, even if it's only
> 0.25 seconds instead of 0.5 seconds.
>
> It would also be nice to know the ratio, like
> 1.1 to 1, or 1.001 to 1.
>
>
> Any ideas?
>

Firstly, it still doesn't matter! The user is not going to be worried by
sub-second time differences. Especially if this represents a tiny tiny
fraction of the total processing time. It really is not worth bothering
with. Your time in maintaining the program is more cost effective.

Having said this, the constants using # notation or not is practically
identical. The interpreter has to always check the first character for a '#'
and then set the numeric base accordingly. Once the base has been set,
converting the text digits into a binary representation of the number is the
same.

With using literals verses constants to reference elements - the interpreter
looks at the first character to work out if its a literal number or a symbol
name. If its a literal it converts it to a number. If its a symbol, it
extracts the symbol name, looks up the symbol table for it, and then
determines if its an integer or not, and finally uses the current value for
the symbol. So, generally speaking, it comes down to which is faster -
converting to binary or looking up the symbol table.

On my machine (Pentium 3, 550MHz) the symbol version took 3.1417215866e-8 or
0.0314 microseconds, and the literal version took 3.152719912e-8 or 0.0315
microseconds. So the speed difference is about 0.0001 microseconds. Taking
your 50,000 cases that works out to be a massive 5 microseconds. Personally,
I can't see the user giving a damn.

--
Derek

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu