Length of variable names and execution speed
5 posts
• Page 1 of 1
Length of variable names and execution speed
I have a very vague idea of what Dyalog APL does when a function is fixed (established) in the workspace. I imagine that it is translated into an internal representation which can be efficiently interpreted. More specifically, are variable names kept intact or are they translated to something shorter for efficient retrieval; in other words can the length of variable names affect the execution speed?
On a side note I lost my first post after my login timed out and I pressed Submit. Not very nice.
On a side note I lost my first post after my login timed out and I pressed Submit. Not very nice.
- augustk
- Posts: 27
- Joined: Tue Feb 05, 2019 11:54 am
Re: Length of variable names and execution speed
Hi,
as far as I know, the variable lengths are no big deal. If I remember it right, the Dyalog guys talk something about using internal tokens here..
For example, let's create following variables with diferent name lengths(in v.18):
...and make three stup..simple functions:
Speed testing them against each other gives no visible difference
Of course, executing takes a tad longer:
But I assume that in normal cases the variable name lengths do not matter.
-Veli-Matti
as far as I know, the variable lengths are no big deal. If I remember it right, the Dyalog guys talk something about using internal tokens here..
For example, let's create following variables with diferent name lengths(in v.18):
a←1e6(?⍴)0 ⋄ b←1e6(?⍴)0
⍎(1e3/'a'),'←a' ⋄ ⍎(1e3/'b'),'←b'
⍎(1e6/'a'),'←a' ⋄ ⍎(1e6/'b'),'←b'
(a+b)≡⍎(1e6/'a'),'+',1e6/'b'
1
...and make three stup..simple functions:
⎕fx'z←foo' 'z←a+b'
⎕fx'z←goo' ('z←',(1e3/'a'),'+',1e3/'b')
⎕fx'z←hoo' ('z←',(1e6/'a'),'+',1e6/'b')
Speed testing them against each other gives no visible difference
]runtime -c "foo" "goo" "hoo"
foo → 2.2E¯3 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
goo → 2.2E¯3 | -1% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
hoo → 2.3E¯3 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Of course, executing takes a tad longer:
]runtime -c "⍎'a+b'" "⍎(1e6/'a'),'+',1e6/'b'"
⍎'a+b' → 2.2E¯3 | 0% ⎕⎕⎕⎕⎕⎕
⍎(1e6/'a'),'+',1e6/'b' → 1.5E¯2 | +591% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
But I assume that in normal cases the variable name lengths do not matter.
-Veli-Matti
- Veli-Matti
- Posts: 93
- Joined: Sat Nov 28, 2009 3:12 pm
Re: Length of variable names and execution speed
Hi AugustK,
When the function is fixed, the APL source is turned into numerical tokens. The names will be indices into a symbol table. The length of the names will not cause a problem or slow performance unless you are using execute like Veli-Matti pointed out.
Regards,
Vince
When the function is fixed, the APL source is turned into numerical tokens. The names will be indices into a symbol table. The length of the names will not cause a problem or slow performance unless you are using execute like Veli-Matti pointed out.
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
Re: Length of variable names and execution speed
Thanks for the clarification, Vince.
- augustk
- Posts: 27
- Joined: Tue Feb 05, 2019 11:54 am
Re: Length of variable names and execution speed
Several years ago we found a number of bugs due to exceedingly long names, so we prevented a number of those bugs by simply limiting the length of a name to something like ¯1+2*31. Mind you, once you get to 2*10 or so I think you'll find that you'll hit problems with ⎕NR etc.
Once you've got your function compiled, then as Veli-Matti and Vince state, the length of a name won't impact the performance of the function. But the longer a name, the longer it will take to open the editor, or generate the output of )si etc etc. And the autocomplete dropdown might take some time to open !
And of course the name has to be held in the workspace .. so the longer the names, the less space there is for other stuff.
Once you've got your function compiled, then as Veli-Matti and Vince state, the length of a name won't impact the performance of the function. But the longer a name, the longer it will take to open the editor, or generate the output of )si etc etc. And the autocomplete dropdown might take some time to open !
And of course the name has to be held in the workspace .. so the longer the names, the less space there is for other stuff.
-
AndyS|Dyalog - Posts: 257
- Joined: Tue May 12, 2009 6:06 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group