Skip to content

Commit 7bef4cc

Browse files
Загрузил(а) файлы в ''
1 parent d501dbf commit 7bef4cc

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

igbinary.inc

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Common php test functions
4+
* Php 4.4+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_11_IGB_serialize()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
12+
13+
if (!function_exists('igbinary_serialize')) {
14+
return $emptyResult;
15+
}
16+
17+
$data = array(
18+
$stringTest,
19+
123456,
20+
123.456,
21+
array(123456),
22+
null,
23+
false,
24+
);
25+
$obj = new stdClass();
26+
$obj->fieldStr = 'value';
27+
$obj->fieldInt = 123456;
28+
$obj->fieldFloat = 123.456;
29+
$obj->fieldArray = array(123456);
30+
$obj->fieldNull = null;
31+
$obj->fieldBool = false;
32+
$data[] = $obj;
33+
34+
$count = $testsLoopLimits['11_igb_serialize'];
35+
$time_start = get_microtime();
36+
for ($i = 0; $i < $count; $i++) {
37+
foreach ($data as $value) {
38+
$r = igbinary_serialize($value);
39+
}
40+
}
41+
$totalOps += $count;
42+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
43+
}
44+
45+
function test_12_IGB_Unserialize()
46+
{
47+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
48+
49+
if (!function_exists('igbinary_unserialize')) {
50+
return $emptyResult;
51+
}
52+
53+
$data = array(
54+
$stringTest,
55+
123456,
56+
123.456,
57+
array(123456),
58+
null,
59+
false,
60+
);
61+
$obj = new stdClass();
62+
$obj->fieldStr = 'value';
63+
$obj->fieldInt = 123456;
64+
$obj->fieldFloat = 123.456;
65+
$obj->fieldArray = array(123456);
66+
$obj->fieldNull = null;
67+
$obj->fieldBool = false;
68+
$data[] = $obj;
69+
70+
foreach ($data as $key => $value) {
71+
$data[$key] = igbinary_serialize($value);
72+
}
73+
74+
$count = $testsLoopLimits['12_igb_unserialize'];
75+
$time_start = get_microtime();
76+
for ($i = 0; $i < $count; $i++) {
77+
foreach ($data as $value) {
78+
$r = igbinary_unserialize($value);
79+
}
80+
}
81+
$totalOps += $count;
82+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
83+
}

msgpack.inc

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Common php test functions
4+
* Php 4.4+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_11_msgpack_pack()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
12+
13+
if (!function_exists('msgpack_pack')) {
14+
return $emptyResult;
15+
}
16+
17+
$data = array(
18+
$stringTest,
19+
123456,
20+
123.456,
21+
array(123456),
22+
null,
23+
false,
24+
);
25+
$obj = new stdClass();
26+
$obj->fieldStr = 'value';
27+
$obj->fieldInt = 123456;
28+
$obj->fieldFloat = 123.456;
29+
$obj->fieldArray = array(123456);
30+
$obj->fieldNull = null;
31+
$obj->fieldBool = false;
32+
$data[] = $obj;
33+
34+
$count = $testsLoopLimits['11_msgpack_pack'];
35+
$time_start = get_microtime();
36+
for ($i = 0; $i < $count; $i++) {
37+
foreach ($data as $value) {
38+
$r = msgpack_pack($value);
39+
}
40+
}
41+
$totalOps += $count;
42+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
43+
}
44+
45+
function test_12_msgpack_unpack()
46+
{
47+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
48+
49+
if (!function_exists('msgpack_unpack')) {
50+
return $emptyResult;
51+
}
52+
53+
$data = array(
54+
$stringTest,
55+
123456,
56+
123.456,
57+
array(123456),
58+
null,
59+
false,
60+
);
61+
$obj = new stdClass();
62+
$obj->fieldStr = 'value';
63+
$obj->fieldInt = 123456;
64+
$obj->fieldFloat = 123.456;
65+
$obj->fieldArray = array(123456);
66+
$obj->fieldNull = null;
67+
$obj->fieldBool = false;
68+
$data[] = $obj;
69+
70+
foreach ($data as $key => $value) {
71+
$data[$key] = msgpack_pack($value);
72+
}
73+
74+
$count = $testsLoopLimits['12_msgpack_unpack'];
75+
$time_start = get_microtime();
76+
for ($i = 0; $i < $count; $i++) {
77+
foreach ($data as $value) {
78+
$r = msgpack_unpack($value);
79+
}
80+
}
81+
$totalOps += $count;
82+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
83+
}

0 commit comments

Comments
 (0)