#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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---