Re: Re: Slowdown
- To: mathgroup at smc.vnet.net
- Subject: [mg53254] Re: [mg53241] Re: Slowdown
- From: yehuda ben-shimol <benshimo at bgu.ac.il>
- Date: Mon, 3 Jan 2005 04:29:31 -0500 (EST)
- References: <cr33tt$je6$1@smc.vnet.net> <200501020912.EAA27775@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Roland,
I'm afraid this is not true. Just try to run the code I sent with my
post. "weirdness" was time consuming while weirdness1 was not. In
addition it happened (not consistently) that function name of a SINGLE
character suffered from this behavior as well.
the code is given below for your convenience.
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, 104}]]]], {i, 1, 50}, {5}]
yehuda
Roland Franzius wrote:
>Maxim wrote:
>
>
>>Consider:
>>
>>In[1]:=
>>Module[{f, L},
>> L = f[];
>> Do[L = f[L, i], {i, 10^4}]
>>] // Timing
>>
>>Module[{weirdness, L},
>> L = weirdness[];
>> Do[L = weirdness[L, i], {i, 10^4}]
>>] // Timing
>>
>>Out[1]=
>>{0.015*Second, Null}
>>
>>Out[2]=
>>{3.063*Second, Null}
>>
>>Here the timings differ by a factor of 200. Besides, the timing grows
>>linearly in the first case and quadratically in the second (therefore, for
>>n=10^5 there will be an approximately 2000 times slowdown). We can only
>>guess that something goes wrong with the symbol name hashing.
>>
>>
>
>The timing difference occurs when the symbol "wierdness" exceeds 8
>characters. Test it for "wierdnes". That seems to be a consequence of
>the machine routine for string comparison. Up to 8 characters can be
>used without using a memory to memory compare. Of course it should be
>possible to write a compare routine that makes not such a bit step.
>
- Follow-Ups:
- Re: Re: Re: Slowdown
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Re: Re: Slowdown
- References:
- Re: Slowdown
- From: Roland Franzius <roland.franzius@uos.de>
- Re: Slowdown