-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
264 lines (193 loc) · 7.03 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
/**
* Single entry point for all HTTP requests
*
* @package Asap
*/
// Fix for nginx
if (empty($_SERVER['REDIRECT_URL']))
{
$sUrl = $_SERVER['REQUEST_URI'];
if ($iPos = strpos($sUrl, '?'))
$sUrl = substr($sUrl, 0, $iPos);
$_SERVER['REDIRECT_URL'] = $sUrl;
}
/*
$iIter = 1000000;
function f1($aData)
{
}
function f2(&$aData)
{
}
$t1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
f1(array('toto' => 'tata', 'tutu' => 'titi', 'tete' => 'tyty', 'trtr' => 'tyru'));
}
$t2 = microtime(true);
echo 'Temps copie : ' . ($t2 - $t1) . '<br />';
$t1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
$aData = array('toto' => 'tata', 'tutu' => 'titi', 'tete' => 'tyty', 'trtr' => 'tyru');
f2($aData);
}
$t2 = microtime(true);
echo 'Temps ref : ' . ($t2 - $t1) . '<br />';
die();
*/
//var_dump($_SERVER['HTTP_ACCEPT_LANGUAGE']);
/*
echo '<br />';
$iIter = 1000000;
$sVal = 'fr-fr';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
list($s1, $s2) = explode('-', $sVal);
$sKey = $s1 . '_' . strtoupper($s2);
}
$f2 = microtime(true);
echo 'Temps explode : ' . ($f2 - $f1) . '<br />';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
$sKey = substr($sVal, 0, 2) . '_' . strtoupper(substr($sVal, 3));
}
$f2 = microtime(true);
echo 'Temps substr : ' . ($f2 - $f1) . '<br />';
die();
*/
//var_dump(get_loaded_extensions());
//var_dump(PDO::MYSQL_ATTR_INIT_COMMAND);
/*
$sText = 'SELECT * FROM coucou WHERE champ1 = ? AND champ2 = ? INNER JOIN toncul ON pepete = infini serialize()qdqdqdqdqsdqsdqsdsqdqsdqsdqsdqsdqsdqsdqsdqsqdqsdqsdqd';
$iIter = 1000000;
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
$sHash = md5($sText);
$f2 = microtime(true);
echo 'Temps md5 : ' . ($f2 - $f1) . '<br />';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
$sHash = sha1($sText);
$f2 = microtime(true);
echo 'Temps sha1 : ' . ($f2 - $f1) . '<br />';
*/
/*
$aData = array(':name' => 'coucou', ':pseudo' => 'emilie', ':age' => 15);
$iIter = 100000;
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
$sHash = serialize($aData);
$f2 = microtime(true);
echo 'Temps serialize : ' . ($f2 - $f1) . '<br />';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
$sHash = '';
foreach ($aData as $sKey => &$sVal)
$sHash .= $sKey . ':' . $sVal . '|';
}
$f2 = microtime(true);
echo 'Temps concat : ' . ($f2 - $f1) . '<br />';
*/
register_shutdown_function('session_write_close');
require_once(dirname(__FILE__) . '/Core/Asap.php');
/*
require_once(ASAP_MAIN_DIR . 'Util/Util.php');
require_once(ASAP_MAIN_DIR . 'Core/Route/Route.php');
require_once(ASAP_MAIN_DIR . 'Util/Timer.php');
*/
//var_dump(ctype_digit('0xFFFFFF'));
//var_dump(ctype_digit(0xFFFFFF));
//var_dump(is_int(0xFFFFFF));
$oAsap = Asap_Core_Asap::init();
//User::findOne(array('test' => array('val1', 'val2', "va'l3")));
/*
require_once('Util/Packer.php');
Asap_Util_Packer::init();
$iIter = 100000;
$sVal = 'fr-fr';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
Asap_Util_Packer::_getFilename1('js');
}
$f2 = microtime(true);
echo 'Temps 1 : ' . ($f2 - $f1) . '<br />';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
Asap_Util_Packer::_getFilename2('js');
}
$f2 = microtime(true);
echo 'Temps 2 : ' . ($f2 - $f1) . '<br />';
die();
*/
$oAsap->routeAndLaunch();
//require_once(ASAP_DIR_MODEL . 'User.php');
//$oUser = new User('coucou');
/*
echo '<br />';
$iIter = 100000;
$iNb2 = 10;
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
$GLOBALS['cache'] = Asap_Cache_Generic::getInstance();
for ($j = 0; $j < $iNb2; $j++)
$oCache = $GLOBALS['cache'];
}
$f2 = microtime(true);
echo 'Temps global : ' . ($f2 - $f1) . '<br />';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
for ($j = 0; $j < $iNb2; $j++)
$oCache = Asap_Cache_Generic::getInstance();
}
$f2 = microtime(true);
echo 'Temps direct : ' . ($f2 - $f1) . '<br />';
$f1 = microtime(true);
for ($i = 0; $i < $iIter; $i++)
{
for ($j = 0; $j < $iNb2; $j++)
$oCache = Asap_Core_Asap::getInstance()->getCache();
}
$f2 = microtime(true);
echo 'Temps indirect : ' . ($f2 - $f1) . '<br />';
*/
/*
$aCheck = array('coucou' => 'caca', 'toto' => 'tata', 'pipi' => 'papa', 'nene' => 'nana', 'zizi' => 'zaza');
$sCheck = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum varius dui ac leo blandit et consectetur tortor pulvinar. Morbi augue tellus, zizi vitae sollicitudin sed, tincidunt vel sem. Curabitur mattis sapien non ante rutrum porta. Aliquam tincidunt sagittis tellus quis rutrum. Aliquam erat volutpat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras eu tellus mi. Sed eleifend vehicula sapien eget porttitor. Duis et nisi sem. Aenean molestie mauris non sem congue eget sagittis felis tempus. Nulla pharetra sollicitudin nisl, nec posuere sapien porta eget. Curabitur luctus mi eu lorem porta eget sodales lorem bibendum.
Nam lacinia arcu nec est nene coucou lacinia nisi lacinia. Integer at ultrices ante. Nam laoreet lacus pipi. Duis lorem leo, facilisis ornare dictum ut, zizi sit amet nisl. Sed hendrerit lobortis nulla ut zizi. Vivamus ac justo velit, vel convallis odio. Nam interdum vestibulum dolor, eget tempor odio vehicula pharetra. Aliquam accumsan purus non sapien sagittis fermentum.
Sed id purus nene. Quisque in mi non orci pretium venenatis sed vel orci. Etiam et libero toto, sed faucibus urna. Curabitur eget mauris nibh, id sollicitudin justo. Ut ut consequat sem. Morbi massa diam, tempor ut volutpat et, tempor vel est. Pellentesque et tellus orci, at vehicula lacus. Suspendisse pulvinar vehicula bibendum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a nulla nec nisl volutpat fringilla et et neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus dapibus, purus id auctor hendrerit, eros diam hendrerit purus, vel mollis ipsum est ut massa. Nunc et porttitor nisl. Morbi sagittis ullamcorper ipsum, at porttitor ante luctus non. Sed in dolor purus. Sed et elit ligula, vitae iaculis ante.';
$oTime = new Timer('strtr');
for ($i = 0; $i < 100000; $i++)
$sStr = strtr($sCheck, $aCheck);
$oTime->stop();
$oTime = new Timer('str_replace');
for ($i = 0; $i < 100000; $i++)
$sStr = str_replace(array_keys($aCheck), array_values($aCheck), $sCheck);
$oTime->stop();
*/
//$oTime = new Timer('array_merge');
//for ($i = 0; $i < 100000; $i++)
//Asap\Core\Asap::getInstance()->getParameter('friends.igor');
//$oTime->stop();
/*
use Asap\Core\Route;
$sRegex = Route::toRegex('/escort/{ville}/{id}-{nom}');
$aParams = Route::extractParams('/escort/{ville}/{id}-{nom}');
var_dump($aParams);
var_dump($sRegex);
$aTest = array('/escort/', '/escort/paris/1234-coucou', '/escort/paris/coucou-124-blabla');
foreach ($aTest as $sTest)
{
$aRes = array();
var_dump(preg_match($sRegex, $sTest, $aRes));
var_dump($aRes);
}
*/