Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F189706
rl_hash.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Krinkle
Jul 7 2015, 7:10 AM
2015-07-07 07:10:09 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
rl_hash.php
View Options
<?php
// Benchmark as part of T102578
require
__DIR__
.
'/includes/WebStart.php'
;
#require '/srv/mediawiki/w/MWVersion.php';
#require getMediaWiki('includes/WebStart.php');
function
kfSafeFilemtime
(
$filePath
)
{
MediaWiki\suppressWarnings
();
$v
=
filemtime
(
$filePath
)
?:
1
;
MediaWiki\restoreWarnings
();
return
$v
;
}
function
kfSafeFileSha1
(
$filePath
)
{
MediaWiki\suppressWarnings
();
$v
=
sha1_file
(
$filePath
)
?:
''
;
MediaWiki\restoreWarnings
();
return
$v
;
}
function
kfSafeFileMd5
(
$filePath
)
{
MediaWiki\suppressWarnings
();
$v
=
md5_file
(
$filePath
)
?:
''
;
MediaWiki\restoreWarnings
();
return
$v
;
}
$dir
=
new
RecursiveDirectoryIterator
(
$IP
.
'/resources'
,
FilesystemIterator
::
SKIP_DOTS
);
$iterator
=
new
RecursiveIteratorIterator
(
$dir
);
$fileCount
=
iterator_count
(
$iterator
);
$data
=
array
();
foreach
(
array
(
'filemtime'
=>
'kfSafeFilemtime'
,
'sha1_file'
=>
'kfSafeFileSha1'
,
'md5_file'
=>
'kfSafeFileMd5'
,
)
as
$method
=>
$fn
)
{
for
(
$i
=
0
;
$i
<
32
;
$i
++)
{
$start
=
microtime
(
true
);
foreach
(
$iterator
as
$key
=>
$value
)
{
$fn
(
$value
);
}
$timing
=
microtime
(
true
)
-
$start
;
if
(
$i
<
2
)
{
$data
[
$method
][
'warmups'
][]
=
$timing
;
}
else
{
$data
[
$method
][
'main'
][]
=
$timing
;
}
}
}
$phpVersion
=
(
wfIsHHVM
()
?
'HHVM '
.
HHVM_VERSION
:
'PHP '
.
PHP_VERSION
)
.
' ('
.
PHP_SAPI
.
')'
;
header
(
'Content-Type: text/html; charset=utf-8'
);
echo
'<h1>Benchmark</h1>'
.
'<p><em>Part of <a href="https://phabricator.wikimedia.org/T102578">T102578</a>.</em></p>'
.
'<table>'
.
'<tr><th>PHP</th><td>'
.
htmlspecialchars
(
$phpVersion
)
.
'</td></tr>'
.
'<tr><th>OS</th><td>'
.
htmlspecialchars
(
PHP_OS
)
.
'</td></tr>'
.
'<tr><th>File pattern</th><td>resources/**/*</td></tr>'
.
'<tr><th>Number of files</th><td>'
.
intval
(
$fileCount
)
.
'</td></tr>'
.
'</table>'
;
foreach
(
$data
as
$method
=>
$data
)
{
echo
"<h2>$method</h2><table>"
;
foreach
(
$data
as
$group
=>
$timings
)
{
echo
"<tr><th>$group</th><td>"
.
((
array_sum
(
$timings
)
/
count
(
$timings
))
*
1000
)
.
'ms total on average ('
.
count
(
$timings
)
.
' samples)'
.
'</td></tr>'
;
}
echo
'</table>'
;
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
181589
Default Alt Text
rl_hash.php (2 KB)
Attached To
Mode
P897 rl_hash.php
Attached
Detach File
Event Timeline
Log In to Comment