1+ <?php 
2+ /** 
3+  * ---------------------------------------------------------------------------- 
4+  * This code is part of the Sclable Business Application Development Platform 
5+  * and is subject to the provisions of your License Agreement with 
6+  * Sclable Business Solutions GmbH. 
7+  * 
8+  * @copyright (c) 2016 Sclable Business Solutions GmbH 
9+  * ---------------------------------------------------------------------------- 
10+  */ 
11+ 
12+ require_once  dirname (__DIR__ ) . '/vendor/autoload.php ' ;
13+ $ instancesinclude  __DIR__  . '/data/listOfInstances.php ' ;
14+ 
15+ $ foreachsclable \arrayFunctions \ArrayWrap::create ([]);
16+ $ mapsclable \arrayFunctions \ArrayWrap::create ([]);
17+ $ mapMethodsclable \arrayFunctions \ArrayWrap::create ([]);
18+ $ wrapMapsclable \arrayFunctions \ArrayWrap::create ([]);
19+ 
20+ for  ($ i0 ; $ i100 ; $ i
21+     // foreach 
22+     $ startmicrotime (true );
23+     $ assigned
24+     foreach  ($ instancesas  $ instance
25+         $ assigned$ instanceid ;
26+     }
27+     $ endmicrotime (true );
28+     $ foreachpush ($ end$ start
29+ 
30+     // map 
31+     $ startmicrotime (true );
32+     $ assigned2array_map (function  ($ instance
33+         return  $ instanceid ;
34+     }, $ instances
35+     $ endmicrotime (true );
36+     $ mapMethodpush ($ end$ start
37+ 
38+     // method call 
39+     $ startmicrotime (true );
40+     $ assigned2array_map ('extractId ' , $ instances
41+     $ endmicrotime (true );
42+     $ mappush ($ end$ start
43+ 
44+     // ArrayWrap map 
45+     $ startmicrotime (true );
46+     $ assigned3sclable \arrayFunctions \ArrayWrap::create ($ instancesmap (function  ($ instance
47+         return  $ instanceid ;
48+     });
49+     $ endmicrotime (true );
50+     $ wrapMappush ($ end$ start
51+ }
52+ 
53+ echo  'foreach:  '  . printResult ($ foreachPHP_EOL ;
54+ echo  'map:  '  . printResult ($ mapPHP_EOL ;
55+ echo  'map method:  '  . printResult ($ mapMethodPHP_EOL ;
56+ echo  'wrapMap:  '  . printResult ($ wrapMapPHP_EOL ;
57+ 
58+ function  printResult (\sclable \arrayFunctions \ArrayWrap   $ results
59+ {
60+     return  "min:  {$ resultsmin ()} / max:  {$ resultsmax ()} / avg:  {$ resultsavg ()} || sum:  {$ resultssum ()}" ;
61+ }
62+ 
63+ function  extractId ($ instance
64+ {
65+     return  $ instanceid ;
66+ }
0 commit comments