-
Notifications
You must be signed in to change notification settings - Fork 27
/
msgpack.inc
83 lines (73 loc) · 1.72 KB
/
msgpack.inc
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
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Common php test functions
* Php 4.4+
*/
/** ---------------------------------- Tests functions -------------------------------------------- */
function test_11_msgpack_pack()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
if (!function_exists('msgpack_pack')) {
return $emptyResult;
}
$data = array(
$stringTest,
123456,
123.456,
array(123456),
null,
false,
);
$obj = new stdClass();
$obj->fieldStr = 'value';
$obj->fieldInt = 123456;
$obj->fieldFloat = 123.456;
$obj->fieldArray = array(123456);
$obj->fieldNull = null;
$obj->fieldBool = false;
$data[] = $obj;
$count = $testsLoopLimits['11_msgpack_pack'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
foreach ($data as $value) {
$r = msgpack_pack($value);
}
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
function test_12_msgpack_unpack()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
if (!function_exists('msgpack_unpack')) {
return $emptyResult;
}
$data = array(
$stringTest,
123456,
123.456,
array(123456),
null,
false,
);
$obj = new stdClass();
$obj->fieldStr = 'value';
$obj->fieldInt = 123456;
$obj->fieldFloat = 123.456;
$obj->fieldArray = array(123456);
$obj->fieldNull = null;
$obj->fieldBool = false;
$data[] = $obj;
foreach ($data as $key => $value) {
$data[$key] = msgpack_pack($value);
}
$count = $testsLoopLimits['12_msgpack_unpack'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
foreach ($data as $value) {
$r = msgpack_unpack($value);
}
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}