-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathtest_url.php
More file actions
43 lines (33 loc) · 1015 Bytes
/
test_url.php
File metadata and controls
43 lines (33 loc) · 1015 Bytes
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
<?php
/**
* Created by PhpStorm.
* User: m_luosu
* Date: 2016/12/27
* Time: 18:06
*/
require_once('./MGQrCodeReader/MGQrCodeReader.php');
// test
$urls = [
'http://ww4.sinaimg.cn/large/a13e4f59gw1fb5juam1duj20a00880to.jpg',
'http://ww1.sinaimg.cn/large/a13e4f59gw1fb5julnh73j20jf0f00uu.jpg'
];
$MGQrCodeReader = new \MGQrCodeReader\MGQrCodeReader();
foreach($urls as $index=>$url) {
$stime = microtime(true);
$smem = convert();
echo '---------', "\n",'start at: ', $stime, "\n",'start mem: ', $smem, "\n";
echo $url, "\n";
echo $MGQrCodeReader->read($url);
$etime = microtime(true);
$emem = convert();
echo "\n",
'end at: ',$etime, "\n",
'end mem: ',$emem, "\n",
'cost time: ', number_format(($etime-$stime), 6, '.', '').' seconds', "\n",
'---------', "\n";
}
function convert(){
$size = memory_get_usage(true);
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}