Re: eval
In article <he1hd7vj.fsf@h otpop.com>, Lasse Reichstein Nielsen <lrn@hotpop.com >
writes:
[color=blue]
>hikksnotathome @aol.com (HikksNotAtHome ) writes:
>[color=green]
>> The first one, John Stocktons site has a textarea for input of
>> script to test it. When testing it, it seems to be the best way to
>> do it (using eval).
>>
>> The other one was a problem I had a while back (it was discussed
>> here) where I had a select list that had fractions as its value.[/color]
>
>I remember that :)
>[color=green]
>> The fractions were random in the sense that they weren't always the
>> same denominator. The problem was trying to convert the fraction to
>> a decimal. It turned out that, in some browsers, eval performed at
>> the same level as splitting on the / and then dividing.[/color]
>
>If it was only at the same level, then I wouldn't use eval. You need
>total control of the arguments to eval (or a syntax check), which should
>outweigh the advantage you get from shorter code.[/color]
The tests that Richard and I did, eval actually outperformed split in IE6. In
the end, I used the split approach for two reasons. First was to try to teach
some inexperienced people another way to do it. Second was so that I wouldn't
have to listen to the same people rail me about "You do what you tell us not to
do".
The control of the arguments wasn't a problem. Whether using eval or the split
method, it would still need to be tested (which in my app it is) to ensure that
nothing got screwy and sent me bad data in the select lists so I don't see that
as a performance hit since I have to do it no matter what approach I use.
[color=blue]
>As for speed. As far as I can see, eval is *much* slower (more tha 5x)
>than using split in IE 6. A little faster yet is finding the "/" with
>indexOf and using substring to get the parts:
> var i = str.indexOf("/");
> return str.substr(0,i)/str.substr(i+1) ;
>
>In Opera 7.2, split was fastest and eval slowest. In MozFB, split and
>eval are comparable. In Netscape 4.8, eval is actually twice as fast
>as split, and 1.5 times as fast as using substring. It is generally
>slower than the other browsers, though.[/color]
The thread at http://tinyurl.com/tw7d shows some of the tests, and discussions,
about the speed impacts.
[color=blue][color=green]
>> Where's the one place you use it?[/color]
>
>A text area for input of scripts (actually the one that I link to in
>this signature).[/color]
That is the use of it that I was referring to with John's site. Didn't know
yours had it as well (I very seldom follow signature URLs).
--
Randy
In article <he1hd7vj.fsf@h otpop.com>, Lasse Reichstein Nielsen <lrn@hotpop.com >
writes:
[color=blue]
>hikksnotathome @aol.com (HikksNotAtHome ) writes:
>[color=green]
>> The first one, John Stocktons site has a textarea for input of
>> script to test it. When testing it, it seems to be the best way to
>> do it (using eval).
>>
>> The other one was a problem I had a while back (it was discussed
>> here) where I had a select list that had fractions as its value.[/color]
>
>I remember that :)
>[color=green]
>> The fractions were random in the sense that they weren't always the
>> same denominator. The problem was trying to convert the fraction to
>> a decimal. It turned out that, in some browsers, eval performed at
>> the same level as splitting on the / and then dividing.[/color]
>
>If it was only at the same level, then I wouldn't use eval. You need
>total control of the arguments to eval (or a syntax check), which should
>outweigh the advantage you get from shorter code.[/color]
The tests that Richard and I did, eval actually outperformed split in IE6. In
the end, I used the split approach for two reasons. First was to try to teach
some inexperienced people another way to do it. Second was so that I wouldn't
have to listen to the same people rail me about "You do what you tell us not to
do".
The control of the arguments wasn't a problem. Whether using eval or the split
method, it would still need to be tested (which in my app it is) to ensure that
nothing got screwy and sent me bad data in the select lists so I don't see that
as a performance hit since I have to do it no matter what approach I use.
[color=blue]
>As for speed. As far as I can see, eval is *much* slower (more tha 5x)
>than using split in IE 6. A little faster yet is finding the "/" with
>indexOf and using substring to get the parts:
> var i = str.indexOf("/");
> return str.substr(0,i)/str.substr(i+1) ;
>
>In Opera 7.2, split was fastest and eval slowest. In MozFB, split and
>eval are comparable. In Netscape 4.8, eval is actually twice as fast
>as split, and 1.5 times as fast as using substring. It is generally
>slower than the other browsers, though.[/color]
The thread at http://tinyurl.com/tw7d shows some of the tests, and discussions,
about the speed impacts.
[color=blue][color=green]
>> Where's the one place you use it?[/color]
>
>A text area for input of scripts (actually the one that I link to in
>this signature).[/color]
That is the use of it that I was referring to with John's site. Didn't know
yours had it as well (I very seldom follow signature URLs).
--
Randy
Comment