Re: [CakePHP : The Rapid Development Framework for PHP] #5742: small optimization for r7864

2008-11-13 Thread CakePHP : The Rapid Development Framework for PHP
#5742: small optimization for r7864
--+-
Reporter:  dardosordi | Owner:  

Type:  Optimization   |Status:  
reopened
Priority:  Low| Milestone:  
1.2.x.x 
   Component:  Controller |   Version:  RC3 

Severity:  Trivial|Resolution:  

Keywords:  optimization,controller,foreach,array_map  |   Php_version:  n/a 

Cake_version:  1.2.0.7692 RC3 |  
--+-
Changes (by dardosordi):

  * status:  closed = reopened
  * resolution:  wontfix =

Comment:

 Ok, so if foreach loops are faster than array_map, shouldn't the core be
 consistent and use foreach loops instead of array_map in the other places
 ?

 [[BR]]

 Anyway, there seems to be another optimization that I didn't realize at
 first sight: don't iterate twice, do the array_diff first and then do the
 foreach/strtolower. I'll attach the diff.

-- 
Ticket URL: https://trac.cakephp.org/ticket/5742#comment:6
CakePHP : The Rapid Development Framework for PHP https://trac.cakephp.org/
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
tickets cakephp group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~--~~~~--~~--~--~---



Re: [CakePHP : The Rapid Development Framework for PHP] #5742: small optimization for r7864

2008-11-12 Thread CakePHP : The Rapid Development Framework for PHP
#5742: small optimization for r7864
--+-
Reporter:  dardosordi | Owner:  

Type:  Optimization   |Status:  
reopened
Priority:  Low| Milestone:  
1.2.x.x 
   Component:  Controller |   Version:  RC3 

Severity:  Trivial|Resolution:  

Keywords:  optimization,controller,foreach,array_map  |   Php_version:  n/a 

Cake_version:  1.2.0.7692 RC3 |  
--+-
Changes (by davidpersson):

  * status:  closed = reopened
  * resolution:  needmoreinfo =

Comment:

 I'm getting different performance results using this snippet:
 http://bin.cakephp.org/view/455012048
 According to that benchmark array_map + strtolower is 3 times faster than
 foreach + strtolower (It seems to depend on the arrays size and/or
 contents).
 The same foreach loop can also be found in
 BehaviorCollection::dispatchMethod.

-- 
Ticket URL: https://trac.cakephp.org/ticket/5742#comment:2
CakePHP : The Rapid Development Framework for PHP https://trac.cakephp.org/
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
tickets cakephp group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~--~~~~--~~--~--~---



Re: [CakePHP : The Rapid Development Framework for PHP] #5742: small optimization for r7864

2008-11-12 Thread CakePHP : The Rapid Development Framework for PHP
#5742: small optimization for r7864
--+-
Reporter:  dardosordi | Owner:  

Type:  Optimization   |Status:  
reopened
Priority:  Low| Milestone:  
1.2.x.x 
   Component:  Controller |   Version:  RC3 

Severity:  Trivial|Resolution:  

Keywords:  optimization,controller,foreach,array_map  |   Php_version:  n/a 

Cake_version:  1.2.0.7692 RC3 |  
--+-
Comment (by dardosordi):

 Replying to [comment:1 renan.saddam]:
  We are always trying to increase the performance. This patch will
 increase the legibility but will decrease the performance.[[BR]]

 [[BR]]
 I actually did my own benchmarks, and array_map is faster in my benchmarks
 (but for a small amount). Anyway array_map is used 35 times in the core,
 many of it's usages (11) are exactly as I'm proposing in the patch.
 [[BR]][[BR]]

 This are my results, I can provide you with my test files if you need them
 but actually I used the getMicrotime() function from the cake core and as
 sample data the array of method names from
 get_class_methods('Controller').

 {{{

 $a1 = array_map('strtolower', $a1); v.s. foreach ($a1 as $k = $v) {
 $a1[$k] = strtolower($v); }


 Iteration   foreach array_map
 
 1   0.00019503  0.00017715
 2   0.00019383  0.00018716
 3   0.00021005  0.00021005
 4   0.00019693  0.00018096
 5   0.00019598  0.00017905
 6   0.00019789  0.00019097
 7   0.00019503  0.00017500
 8   0.00022793  0.00044584
 9   0.00019598  0.00018501
 10  0.00019312  0.00018692
 11  0.00019598  0.00018501
 12  0.00020003  0.00018883
 13  0.00019908  0.00018311
 14  0.00020289  0.00018096
 15  0.00019789  0.00017691
 16  0.00019693  0.00017500
 17  0.00045705  0.00017786
 18  0.00019288  0.00017595
 19  0.00020099  0.00018096
 20  0.00019312  0.00017595
 
 min 0.00019288  0.00017500
 max 0.00045705  0.00044584
 average 0.00021193  0.00019593

 }}}

-- 
Ticket URL: https://trac.cakephp.org/ticket/5742#comment:3
CakePHP : The Rapid Development Framework for PHP https://trac.cakephp.org/
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
tickets cakephp group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~--~~~~--~~--~--~---



Re: [CakePHP : The Rapid Development Framework for PHP] #5742: small optimization for r7864

2008-11-12 Thread CakePHP : The Rapid Development Framework for PHP
#5742: small optimization for r7864
--+-
Reporter:  dardosordi | Owner:  

Type:  Optimization   |Status:  
reopened
Priority:  Low| Milestone:  
1.2.x.x 
   Component:  Controller |   Version:  RC3 

Severity:  Trivial|Resolution:  

Keywords:  optimization,controller,foreach,array_map  |   Php_version:  n/a 

Cake_version:  1.2.0.7692 RC3 |  
--+-
Comment (by jose.zap):

 Googling whether array_map is faster then foreach or not, I found on every
 blog that array_mapm is in some cases 3x faster than a normal loop. I will
 do my own bechmarks to test if that is true.

-- 
Ticket URL: https://trac.cakephp.org/ticket/5742#comment:4
CakePHP : The Rapid Development Framework for PHP https://trac.cakephp.org/
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
tickets cakephp group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~--~~~~--~~--~--~---