-
Notifications
You must be signed in to change notification settings - Fork 0
/
empty.php
59 lines (44 loc) · 1.32 KB
/
empty.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
<?php
#$INTERVAL = 1_000_000_000;
$INTERVAL = 100_000_000;
#$INTERVAL = 1_000_000;
#$INTERVAL = 100_000;
$array = array( 'update_core', 'update_plugins', 'update_themes', 'update_core', 'update_plugins', 'update_core', 'update_plugins', 'update_themes', 'update_core', 'update_core', 'update_plugins', 'update_themes', 'update_core', 'update_core', 'update_plugins', 'update_themes', 'update_core', 'update_core', 'update_plugins', 'update_themes', 'update_core', 'update_core', 'update_plugins', 'update_themes', 'update_core', 'update_core', 'update_plugins', 'update_themes', 'update_core', 'update_core', 'update_plugins', 'update_themes', 'update_core' );
#$array = array();
echo "empty ";
$stop = $INTERVAL;
$start = microtime(true);
while(--$stop)
{
if ( !empty ( $array ) ){
/*
*/
}
}
echo number_format(microtime(true) - $start, 5)." secs\n\n";
echo "count === ";
$stop = $INTERVAL;
$start = microtime(true);
while(--$stop)
{
if ( count ( $array ) === 0 ) {
/*
*/
}
}
echo number_format(microtime(true) - $start, 5)." secs\n\n";
echo "count == ";
$stop = $INTERVAL;
$start = microtime(true);
while(--$stop)
{
if ( count ( $array ) == 0 ) {
/*
*/
}
}
echo number_format(microtime(true) - $start, 5)." secs\n\n";
//OUTPUT:
//empty 0.77974 secs
//count === 0.80511 secs
//count == 0.68375 secs