For Programmers: Free Programming Magazines  


Home > Archive > Rexx > October 2006 > Length of variable name & affect on performance?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Length of variable name & affect on performance?
John

2006-10-04, 7:02 pm

I've heard that the longer your variable names, the more impact this could
have on script performance. Is there any credence to this in REXX?

Based on performance testing from a previous thread, I ran a jury-rig test
like this:
/* rexx */
t = time('r'); do i=1 for 1000000; a=0; end; say time('e')
t = time('r'); do i=1 for 1000000; a1111111=0; end; say time('e')

That second "a1111" actually has 49 1's after it but I cut them out for this
post.

They both ran in about the same time; usually, for some reason, the longer
varname loop ran quicker, though I only tested this a couple of times,
switching the order of the loops.

I think I heard that ooRexx interprets the whole script before it executes,
whereas, for instance, mainframe TSO will interpret line-by-line during
execution. Does this make a difference or am I chasing a red herring here?
It's hard to do stress tests like this on a mainframe since the system's
workload can peak & valley unpredictably at any time.


i

2006-10-05, 4:06 am

John wrote:
> I've heard that the longer your variable names, the more impact this could
> have on script performance. Is there any credence to this in REXX?


<snip>

AFAIK, there is one "documented" performance enhancement regarding
variable names in rexx: one character length variable names.
Presumable for small loops.

Other than that, I suspect that variable name length have minimal
impact on performance as I think rexx e g uses a numeric "handle" for
variables after the first use.
(And maybe stores the names in a internal table etc.)
Of course, the longer the names (and for a lot of them) the memory
footprint increases. And that could impact performance.

Rick McGuire

2006-10-05, 4:06 am

John wrote:
> I've heard that the longer your variable names, the more impact this could
> have on script performance. Is there any credence to this in REXX?
>
> Based on performance testing from a previous thread, I ran a jury-rig test
> like this:
> /* rexx */
> t = time('r'); do i=1 for 1000000; a=0; end; say time('e')
> t = time('r'); do i=1 for 1000000; a1111111=0; end; say time('e')
>
> That second "a1111" actually has 49 1's after it but I cut them out for this
> post.
>
> They both ran in about the same time; usually, for some reason, the longer
> varname loop ran quicker, though I only tested this a couple of times,
> switching the order of the loops.
>
> I think I heard that ooRexx interprets the whole script before it executes,
> whereas, for instance, mainframe TSO will interpret line-by-line during
> execution. Does this make a difference or am I chasing a red herring here?
> It's hard to do stress tests like this on a mainframe since the system's
> workload can peak & valley unpredictably at any time.
>
>


It depends on the implementation. On the mainframe Rexx version, all
variables references are looked up dynamically in a variable dictionary,
so a shorter variable name will match successfully maybe a tiny bit more
quickly than a longer one. But this is modified by other factors as
well, such as the fact the variables are stored in a balanced binary
tree which gets modified dynamically as new variables get created. A
long variable name near the root might be located more quickly than a
shorter variable that's pushed out to a leaf node. This may very well
be what's happening with your benchmark above to cause the longer name
loop to run faster.

ooRexx, on the other hand, uses an optimization for variable access that
does not require a search on the variable name. Other than the small
difference in scan time performance, there should be no difference
between long names or short names.

As an optimization technique, I'd classify this in the "fagedaboutit"
category. You're much better off writing readable code and focusing on
the algorithmic changes to improve the performance. This sort of
reminds me of a discussion from about 20 years ago about the impact of
comments on Rexx performance.

Rick

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com