Re: Slowdown

• To: mathgroup at smc.vnet.net
• Subject: [mg53228] Re: [mg53220] Slowdown
• From: "yehuda ben-shimol" <benshimo at bgumail.bgu.ac.il>
• Date: Sat, 1 Jan 2005 02:33:48 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Maxim,
I assume that you are right. There is a problem. First I tried to test it
with a much longer function name
So as a reference point (since we have different computers) I started with

Module[{f, L},
L = f[];
Do[L = f[L, i], {i, 10^5}];
] // Timing

And got
{0.25 Second, Null}

Module[{weirdness, L},
L = weirdness[];
Do[L = weirdness[L, i], {i, 10^4}];
] // Timing

{4.517 Second, Null}

With a long name
Module[{IWantAVeryLongNameToTheFunction, L},
L = IWantAVeryLongNameToTheFunction[];
Do[L = IWantAVeryLongNameToTheFunction[L, i], {i, 10^4}];
] // Timing

{0.02 Second, Null}

OOPS, this is interesting

So I enlarged the name of the function, but in a "predicted fashion"
Module[{IWantAVeryVeryVeryVeryVeryVeryVeryVeryVeryLongNameToTheFunction, L},
L = IWantAVeryVeryVeryVeryVeryVeryVeryVeryVeryLongNameToTheFunction[];
Do[L = IWantAVeryVeryVeryVeryVeryVeryVeryVeryVeryLongNameToTheFunction[L,
\
i], {i, 10^4}];
] // Timing

And got again
{0.02 Second, Null}

Ha, this is interesting. So I assume that there is something in the
structure of the name that makes the hashing inefficient in some way
I wrote a rather simple code to test the problem and found INTERESTING
results. It generates a random function name of increasing length starting
from a single character to 50 characters. For each length I repeated 5
times, each time with a (probably) different name.
Since you need to observe it yourself, on your machine, I suggest that you
run the following code and check the (emuzing) results yourself.

t = CharacterRange["a", "z"];
Do[fname = StringJoin[t[[Table[Random[Integer, {1,26}], {i}]]]];
Print[i, "\t", fname, "\t",
Timing[
Module[{fs = ToExpression[fname], L},
L = fs[];
Do[L = fs[L, j], {j, 10^4}]]]], {i, 1, 50}, {5}]

This rather simple "computer experiment" on Mathematica (as S. Wolfram might
say) shows that the timing problem is not dependent on the length of the
function name (at least until length 50 that I checked).
I couldn't believe that the performance depends on the function's name??????
Can we get a comment from one of the WRI professionals on that issue?
yehuda

```

• Prev by Date: Re: Re: Re: Matrix Operator form using Mathematica
• Next by Date: Re: Slowdown
• Previous by thread: Re: Slowdown
• Next by thread: Re: Slowdown