⚲
Project
General
Profile
Sign in
Home
Projects
Help
Search
:
TYPO3 Core
All Projects
TYPO3 Core
Overview
Activity
Roadmap
Issues
Repository
Download (906 Bytes)
Bug #23113
» 15020_testInt_test_v1.php
Administrator Admin, 2010-07-06 23:43
<?php
$times
=
30000
;
function
testInt
(
$var
)
{
return
!
strcmp
(
$var
,
intval
(
$var
));
}
function
testIntVariant1
(
$var
)
{
return
is_int
(
$var
);
}
function
test
(
$function
,
$a
,
$b
)
{
global
$times
;
$time_start
=
microtime
(
TRUE
);
for
(
$i
=
0
;
$i
<
$times
;
$i
++
)
{
$function
(
$a
,
$b
);
}
return
(
microtime
(
TRUE
)
-
$time_start
);
}
$testcases
=
array
(
'int'
=>
array
(
'32425'
,
),
'string'
=>
array
(
'the quick brown fox'
),
'NULL'
=>
array
(
NULL
),
'array str'
=>
array
(
array
(
'a'
,
'b'
),
),
);
foreach
(
$testcases
as
$name
=>
$parameters
)
{
echo
"
\n
$name
"
;
$baseTime
=
test
(
'testInt'
,
$parameters
[
0
],
$parameters
[
1
]);
echo
"
\n
original : "
.
sprintf
(
"%.3f"
,
$baseTime
);
$time
=
test
(
'testIntVariant1'
,
$parameters
[
0
],
$parameters
[
1
]);
echo
"
\n
variant1 : "
.
sprintf
(
"%.3f"
,
$time
)
.
' gain '
.
number_format
(((
$baseTime
/
$time
)
*
100
)
-
100
,
1
)
.
' %'
;
echo
"
\n
"
;
}
?>
« Previous
1
2
Next »
(2-2/2)
Loading...