-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.php
71 lines (54 loc) · 1.52 KB
/
data.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
60
61
62
63
64
65
66
67
68
69
70
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
$format = $_GET["encoder"];
$entries = $_GET["entries"];
$list = array();
for( $i = 0; $i < $entries; $i++)
{
$a = array("name" => "filename".$i.".extension", "mtime" => "1997-07-16T19:20:30+00:00", "size" => 1231234, "md5"=>"sdfasfarf4r5sf");
$list[] = $a;
}
$s = "";
if($format == "buildin-json")
{
$start = microtime(true);
$s = json_encode($list);
$end = microtime (true);
}
if($format == "simplexml-attibutes")
{
$start = microtime(true);
$xml = new SimpleXMLElement('<xml/>');
foreach($list as $element)
{
$track = $xml->addChild('file');
$track->addAttribute('name', $element["name"]);
$track->addAttribute('mtime', $element["mtime"]);
$track->addAttribute('size', $element["size"]);
$track->addAttribute('md5', $element["md5"]);
}
$s = $xml->asXML();
$end = microtime(true);
}
if($format == "simplexml-childnodes")
{
$start = microtime(true);
$xml = new SimpleXMLElement('<xml/>');
foreach($list as $element)
{
$track = $xml->addChild('file');
$track->addChild('name', $element["name"]);
$track->addChild('mtime', $element["mtime"]);
$track->addChild('size', $element["size"]);
$track->addChild('md5', $element["md5"]);
}
$s = $xml->asXML();
$end = microtime(true);
}
header("X-encodingDuration: ".($end-$start)*1000000); //In micreoseconds seconds
header("X-encodedSize: ".strlen($s));
header("X-encoder: ".($format));
echo $s;
?>