Re: [PHP] Associative Array Benchmarking

2004-09-19 Thread Michal Migurski
> Although I'm not certain how well known this is, I thought I'd share
> this with everyone who might have wondered if there was a benefit to
> using or not using quotes when referencing associative arrays.

The benefit to using quotes is that it's the right thing to do, unless
you're looking for constants instead of strings. Sometimes a quick R of
the first few chapters in TFM beats a benchmark.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Associative Array Benchmarking

2004-09-19 Thread Curt Zirzow
* Thus wrote bskolb:
>  
> Benchmark results:
>  
> Function assocArrayWithQuotes() ran 50 times in 4.4331 seconds.
> Function assocArrayWithoutQuotes() ran 50 times in 6.4170 seconds.
>  
> The only difference in the two functions is the use of quotes, one with and
> the other without.

That is because the  one without the quotes, php first checks to
see if a constant is defined with that name, if not then the
literal value will be used.


Curt
-- 
The above comments may offend you. flame at will.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Associative Array Benchmarking

2004-09-18 Thread Jason Wong
On Sunday 19 September 2004 09:33, bskolb wrote:
> Although I'm not certain how well known this is, I thought I'd share this
> with everyone who might have wondered if there was a benefit to using or
> not using quotes when referencing associative arrays.

You should be using single quotes rather than no quotes.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If a program actually fits in memory and has enough disk space, it is 
guaranteed to crash. 
-- Murphy's Computer Laws n5
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Associative Array Benchmarking

2004-09-18 Thread bskolb
Although I'm not certain how well known this is, I thought I'd share this
with everyone who might have wondered if there was a benefit to using or not
using quotes when referencing associative arrays.
 
While benchmarking a few different array sorting options, I had used
in_array and search_array.  I noticed that one was more than 30% faster than
the other.  On further investigation I realized I had used quotes one one
and not the other.  
 
Benchmark results:
 
Function assocArrayWithQuotes() ran 50 times in 4.4331 seconds.
Function assocArrayWithoutQuotes() ran 50 times in 6.4170 seconds.
 
The only difference in the two functions is the use of quotes, one with and
the other without.
 
 
Flame at will.