Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P17048
preg_match timing loop
Active
Public
Actions
Authored by
dancy
on Aug 19 2021, 3:11 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F34606345: preg_match timing loop
Aug 19 2021, 3:11 PM
2021-08-19 15:11:18 (UTC+0)
Subscribers
Legoktm
<?php
$start
=
microtime
(
true
);
$loops
=
1000
*
1000
;
for
(
$i
=
0
;
$i
<
$loops
;
$i
++)
{
$etcdHost
=
"_etcd._tcp.eqiad.wmnet"
;
$protocol
=
'https'
;
if
(
preg_match
(
',^(https?)://(.*)$,'
,
$etcdHost
,
$matches
)
)
{
$protocol
=
$matches
[
1
];
$etcdHost
=
$matches
[
2
];
}
}
$elapsed
=
microtime
(
true
)
-
$start
;
$per_loop
=
$elapsed
/
$loops
;
$us_per_loop
=
$per_loop
*
1000
*
1000
;
$ns_per_loop
=
$per_loop
*
1000
*
1000
*
1000
;
echo
(
"Elapsed seconds: $elapsed
\n
"
);
echo
(
"Seconds per loop: $per_loop
\n
"
);
echo
(
"us per loop: $us_per_loop
\n
"
);
echo
(
"ns per loop: $ns_per_loop
\n
"
);
Event Timeline
dancy
created this paste.
Aug 19 2021, 3:11 PM
2021-08-19 15:11:18 (UTC+0)
Log In to Comment