MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Slowdown

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53242] Re: Slowdown
  • From: Peter Pein <petsie at arcor.de>
  • Date: Sun, 2 Jan 2005 04:12:52 -0500 (EST)
  • References: <cr5k8m$18l$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

yehuda ben-shimol wrote:
...
> 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
> 

That's funny. I just have been lucky not to get trapped? I modified your 
code to generate function names consisting of n times the same letter. 
Here's what I got for the length of the name from 1 to 50 (Mathematica 4):

In[1]:=
tlist = Complement[Join[CharacterRange["a", "z"], CharacterRange["A", "Z"]],
   ToString /@ {B, C, D, E, I, M, N, O, V}];
weird[n_] := Extract[ToExpression[tlist], Position[
      (1/Second*First[Timing[
           Module[{fs = ToExpression[StringJoin @@ Table[#1,{n}]], L}, L 
= fs[];
             Do[L = fs[L, j],
             {j, 1000}]]]] & ) /@ tlist,
      x_ /; x > 0.02 (*adjust this*)]];
wlist = weird /@ Range[12]

Out[3]=
{{J, l, L, w, W, y, Y},
  {j, J, l, L, w, W, y, Y},
  {j, J, l, L, w, W, y, Y},
  {g, G, m, t, T, z, Z},
  {g, G, m, t, T, z, Z},
  {g, G, m, t, T, z, Z},
  {g, G, m, t, T, z, Z},
  {},
  {},
  {},
  {},
  {j, J, l, L, w, W, y, Y}}

For k>=1 the "slow" letters are the same for the lengths 4k..4k+3:

In[4]:=
weird /@ Range[396, 403]
Out[4]=
{{j, J, l, L, w, W, y, Y}, {j, J, l, L, w, W, y, Y},
  {j, J, l, L, w, W, y, Y}, {j, J, l, L, w, W, y, Y},
  {g, G, t, T, z, Z}, {g, G, t, T, z, Z},
  {g, G, t, T, z, Z}, {g, G, t, T, z, Z}}

strange, isn't it?

-- 
Peter Pein
Berlin


  • Prev by Date: Re: Re: Slowdown
  • Next by Date: Re: Re: Slowdown
  • Previous by thread: Re: Re: Slowdown
  • Next by thread: Re: Slowdown