-
Notifications
You must be signed in to change notification settings - Fork 27
/
igbinary.inc
83 lines (73 loc) · 1.75 KB
/
igbinary.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_IGB_serialize()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
if (!function_exists('igbinary_serialize')) {
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_igb_serialize'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
foreach ($data as $value) {
$r = igbinary_serialize($value);
}
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
function test_12_IGB_Unserialize()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
if (!function_exists('igbinary_unserialize')) {
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] = igbinary_serialize($value);
}
$count = $testsLoopLimits['12_igb_unserialize'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
foreach ($data as $value) {
$r = igbinary_unserialize($value);
}
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}