Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
naming of variables affect

Subject: naming of variables affect

From: pink

Date: 7 Jun, 2011 18:55:22

Message: 1 of 18

whether the naming of variables affect the speed of a program analysis?

Subject: naming of variables affect

From: ImageAnalyst

Date: 7 Jun, 2011 19:57:28

Message: 2 of 18

On Jun 7, 2:55 pm, "pink " <wahyoe_slip...@yahoo.co.id> wrote:
> whether the naming of variables affect the speed of a program analysis?

---------------------------------------
Why would you think that?

Subject: naming of variables affect

From: pink

Date: 7 Jun, 2011 21:02:04

Message: 3 of 18

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <fffa81d7-beab-43e9-8c8e-2f684544d0ea@f2g2000yqh.googlegroups.com>...
> On Jun 7, 2:55 pm, "pink " <wahyoe_slip...@yahoo.co.id> wrote:
> > whether the naming of variables affect the speed of a program analysis?
>
> ---------------------------------------
> Why would you think that?

hy
eg "data_input_adrees =....+ ....+...+" or "she =....+ ....+...+"
whether the longer the naming of variables have an impact?

Subject: naming of variables affect

From: Husam Aldahiyat

Date: 7 Jun, 2011 21:08:04

Message: 4 of 18

"pink" wrote in message <ism3kc$h4f$1@newscl01ah.mathworks.com>...
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message <fffa81d7-beab-43e9-8c8e-2f684544d0ea@f2g2000yqh.googlegroups.com>...
> > On Jun 7, 2:55 pm, "pink " <wahyoe_slip...@yahoo.co.id> wrote:
> > > whether the naming of variables affect the speed of a program analysis?
> >
> > ---------------------------------------
> > Why would you think that?
>
> hy
> eg "data_input_adrees =....+ ....+...+" or "she =....+ ....+...+"
> whether the longer the naming of variables have an impact?

The impact is very very very very very little and not noticeable. It is not even worth thinking about at all.

Subject: naming of variables affect

From: ImageAnalyst

Date: 7 Jun, 2011 21:21:47

Message: 5 of 18

I would say no. Don't give it a second thought. What you should
really be worrying about is choosing descriptive variable names that
will be easily understood by someone (or yourself) who has to maintain
this code in the future, when you're not around to explain it to
them. In other words, use variable names like "grayImage" or
"rgbImage" instead of "I" or other short, cryptic one or two letter
variable names. For example, #6 in this thread (http://
www.mathworks.com/matlabcentral/newsreader/view_thread/303878#823220)
is a perfect example of poorly written, uncommented, incomprehensible,
and utterly unmaintainable code.
ImageAnalyst

Subject: naming of variables affect

From: pink

Date: 7 Jun, 2011 21:22:04

Message: 6 of 18

"Husam Aldahiyat" wrote in message <ism3vk$i1q$1@newscl01ah.mathworks.com>...
> "pink" wrote in message <ism3kc$h4f$1@newscl01ah.mathworks.com>...
> > ImageAnalyst <imageanalyst@mailinator.com> wrote in message <fffa81d7-beab-43e9-8c8e-2f684544d0ea@f2g2000yqh.googlegroups.com>...
> > > On Jun 7, 2:55 pm, "pink " <wahyoe_slip...@yahoo.co.id> wrote:
> > > > whether the naming of variables affect the speed of a program analysis?
> > >
> > > ---------------------------------------
> > > Why would you think that?
> >
> > hy
> > eg "data_input_adrees =....+ ....+...+" or "she =....+ ....+...+"
> > whether the longer the naming of variables have an impact?
>
> The impact is very very very very very little and not noticeable. It is not even worth thinking about at all.

thanks husam

Subject: naming of variables affect

From: Matt J

Date: 7 Jun, 2011 21:42:05

Message: 7 of 18

In fact, the JIT can make it appear as though longer variable names are better. See comparison below:


N=1e7;

tic;
for ii=1:N
      
 A=rand;
 
end
toc; %Elapsed time is 0.513593 seconds.

tic;
for ii=1:N
    

 VariableWithALoooooooooooooooooooooooooooooooooooooooongName=rand;
 
end
toc;%Elapsed time is 0.395702 seconds.

Subject: naming of variables affect

From: pink

Date: 7 Jun, 2011 21:53:04

Message: 8 of 18

"Matt J" wrote in message <ism5vd$n9b$1@newscl01ah.mathworks.com>...
> In fact, the JIT can make it appear as though longer variable names are better. See comparison below:
>
>
> N=1e7;
>
> tic;
> for ii=1:N
>
> A=rand;
>
> end
> toc; %Elapsed time is 0.513593 seconds.
>
> tic;
> for ii=1:N
>
>
> VariableWithALoooooooooooooooooooooooooooooooooooooooongName=rand;
>
> end
> toc;%Elapsed time is 0.395702 seconds.
thanks, Matt

Subject: naming of variables affect

From: Steven_Lord

Date: 8 Jun, 2011 13:55:19

Message: 9 of 18



"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message
news:ism5vd$n9b$1@newscl01ah.mathworks.com...
> In fact, the JIT can make it appear as though longer variable names are
> better. See comparison below:
>
>
> N=1e7;
>
> tic;
> for ii=1:N
> A=rand;
>
> end
> toc; %Elapsed time is 0.513593 seconds.
>
> tic;
> for ii=1:N
>
> VariableWithALoooooooooooooooooooooooooooooooooooooooongName=rand;
>
> end
> toc;%Elapsed time is 0.395702 seconds.

First, I assume you ran this benchmarking code in a function file rather
than a script file?

Second, did you run this block of code several times to remove the "first
run" effect?

I think if you do this you'll see that the difference in timing per run is
extremely small, and the effect of the variable name length (if any) is
swamped by many, many other factors (like memory swapping, OS or
applications phoning home, etc.)

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: naming of variables affect

From: Matt J

Date: 13 Jul, 2011 15:00:32

Message: 10 of 18

"Steven_Lord" <slord@mathworks.com> wrote in message <isnv07$gf7$1@newscl01ah.mathworks.com>...
>
>
> First, I assume you ran this benchmarking code in a function file rather
> than a script file?
=============

Yes.


 
> Second, did you run this block of code several times to remove the "first
> run" effect?

Yes.

> I think if you do this you'll see that the difference in timing per run is
> extremely small, and the effect of the variable name length (if any) is
> swamped by many, many other factors (like memory swapping, OS or
> applications phoning home, etc.)
===============

Nope. The difference is substantial and persistent.

Subject: naming of variables affect

From: Steven_Lord

Date: 13 Jul, 2011 15:15:57

Message: 11 of 18



"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message
news:ivkbug$dmf$1@newscl01ah.mathworks.com...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> <isnv07$gf7$1@newscl01ah.mathworks.com>...
>>
>>
>> First, I assume you ran this benchmarking code in a function file rather
>> than a script file?
> =============
>
> Yes.
>
>> Second, did you run this block of code several times to remove the "first
>> run" effect?
>
> Yes.
>
>> I think if you do this you'll see that the difference in timing per run
>> is extremely small, and the effect of the variable name length (if any)
>> is swamped by many, many other factors (like memory swapping, OS or
>> applications phoning home, etc.)
> ===============
>
> Nope. The difference is substantial and persistent.

Hmm. Then you should send this in to Technical Support so we can determine
what's going on and why the difference in the timing values are so large.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: naming of variables affect

From: Steve Eddins

Date: 13 Jul, 2011 15:37:36

Message: 12 of 18

On 7/13/2011 11:15 AM, Steven_Lord wrote:
>
>
> "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message
> news:ivkbug$dmf$1@newscl01ah.mathworks.com...
>> "Steven_Lord" <slord@mathworks.com> wrote in message
>> <isnv07$gf7$1@newscl01ah.mathworks.com>...
>>>
>>>
>>> First, I assume you ran this benchmarking code in a function file
>>> rather than a script file?
>> =============
>>
>> Yes.
>>
>>> Second, did you run this block of code several times to remove the
>>> "first run" effect?
>>
>> Yes.
>>
>>> I think if you do this you'll see that the difference in timing per
>>> run is extremely small, and the effect of the variable name length
>>> (if any) is swamped by many, many other factors (like memory
>>> swapping, OS or applications phoning home, etc.)
>> ===============
>>
>> Nope. The difference is substantial and persistent.
>
> Hmm. Then you should send this in to Technical Support so we can
> determine what's going on and why the difference in the timing values
> are so large.
>

Steve, I just tried this in R2011a. I saw no difference in speed. I
tried it two ways, with the code in a function and in a script, and
timed it carefully.

--
Steve Eddins
http://blogs.mathworks.com/steve/

Subject: naming of variables affect

From: Matt J

Date: 13 Jul, 2011 15:53:10

Message: 13 of 18

"Steve Eddins" wrote in message <ivke40$klm$1@newscl01ah.mathworks.com>...
> On 7/13/2011 11:15 AM, Steven_Lord wrote:
>
>
> Steve, I just tried this in R2011a. I saw no difference in speed. I
> tried it two ways, with the code in a function and in a script, and
> timed it carefully.
============

Well, then it must be a platform dependent thing, because I just tested it both in R2010b and R2011a, with the same results as I claimed previously.

Subject: naming of variables affect

From: Steve Eddins

Date: 13 Jul, 2011 17:34:01

Message: 14 of 18

On 7/13/2011 11:53 AM, Matt J wrote:
> "Steve Eddins" wrote in message <ivke40$klm$1@newscl01ah.mathworks.com>...
>> On 7/13/2011 11:15 AM, Steven_Lord wrote:
>>
>>
>> Steve, I just tried this in R2011a. I saw no difference in speed. I
>> tried it two ways, with the code in a function and in a script, and
>> timed it carefully.
> ============
>
> Well, then it must be a platform dependent thing, because I just tested
> it both in R2010b and R2011a, with the same results as I claimed
> previously.

What platform are you using?

--
Steve Eddins
http://blogs.mathworks.com/steve/

Subject: naming of variables affect

From: Matt J

Date: 13 Jul, 2011 17:54:25

Message: 15 of 18

"Steve Eddins" wrote in message <ivkku9$cn9$1@newscl01ah.mathworks.com>...
>
> > Well, then it must be a platform dependent thing, because I just tested
> > it both in R2010b and R2011a, with the same results as I claimed
> > previously.
>
>
> What platform are you using?
>


Dell Latitude E6500
Intel Core 2 Duo
T9550 @2.66 GHz
2.66GHz, 3.48 GB RAM

Subject: naming of variables affect

From: Steve Eddins

Date: 18 Jul, 2011 15:13:07

Message: 16 of 18

"Matt J" wrote in message <ivkm4h$gta$1@newscl01ah.mathworks.com>...
> "Steve Eddins" wrote in message <ivkku9$cn9$1@newscl01ah.mathworks.com>...
> >
> > > Well, then it must be a platform dependent thing, because I just tested
> > > it both in R2010b and R2011a, with the same results as I claimed
> > > previously.
> >
> >
> > What platform are you using?
> >
>
>
> Dell Latitude E6500
> Intel Core 2 Duo
> T9550 @2.66 GHz
> 2.66GHz, 3.48 GB RAM

It's a mystery to me.

Subject: naming of variables affect

From: Matt J

Date: 18 Jul, 2011 15:35:09

Message: 17 of 18

"Steve Eddins" wrote in message <j01ii3$1ja$1@newscl01ah.mathworks.com>...
>
> > > What platform are you using?
> > >
> >
> >
> > Dell Latitude E6500
> > Intel Core 2 Duo
> > T9550 @2.66 GHz
> > 2.66GHz, 3.48 GB RAM
>
> It's a mystery to me.
================

Does that mean you were able to reproduce it? Or do you just mean that it sounds weird?

Subject: naming of variables affect

From: Steve Eddins

Date: 18 Jul, 2011 15:37:37

Message: 18 of 18

On 7/18/2011 11:35 AM, Matt J wrote:
> "Steve Eddins" wrote in message <j01ii3$1ja$1@newscl01ah.mathworks.com>...
>>
>> > > What platform are you using?
>> > >
>> > > > Dell Latitude E6500
>> > Intel Core 2 Duo > T9550 @2.66 GHz
>> > 2.66GHz, 3.48 GB RAM
>>
>> It's a mystery to me.
> ================
>
> Does that mean you were able to reproduce it? Or do you just mean that
> it sounds weird?

Both.

--
Steve Eddins
http://blogs.mathworks.com/steve/

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us