-
Notifications
You must be signed in to change notification settings - Fork 27
/
compression.inc
109 lines (90 loc) · 2.76 KB
/
compression.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* Common php test functions
* Php 4.4+
*/
/** ---------------------------------- Tests functions -------------------------------------------- */
function test_36_zlib_compress()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps, $stringTest;
if (!function_exists('gzdeflate')) {
return $emptyResult;
}
$count = $testsLoopLimits['36_zlib_compress'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
$r = gzdeflate($stringTest, 1);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
function test_36_gzip_compress()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps, $stringTest;
if (!function_exists('gzencode')) {
return $emptyResult;
}
$count = $testsLoopLimits['36_gzip_compress'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
$r = gzencode($stringTest, 1);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
function test_36_bzip2_compress()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps, $stringTest;
if (!function_exists('bzcompress')) {
return $emptyResult;
}
$count = $testsLoopLimits['36_bzip2_compress'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
$r = bzcompress($stringTest, 1);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
function test_36_lz4_compress()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps, $stringTest;
if (!function_exists('lz4_compress')) {
return $emptyResult;
}
$count = $testsLoopLimits['36_bzip2_compress'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
$r = lz4_compress($stringTest);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
function test_36_zstd_compress()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps, $stringTest;
if (!function_exists('zstd_compress')) {
return $emptyResult;
}
$count = $testsLoopLimits['36_zstd_compress'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
$r = zstd_compress($stringTest, 1);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}
function test_36_brotli_compress()
{
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps, $stringTest;
if (!function_exists('brotli_compress')) {
return $emptyResult;
}
$count = $testsLoopLimits['36_brotli_compress'];
$time_start = get_microtime();
for ($i = 0; $i < $count; $i++) {
$r = brotli_compress($stringTest, 1);
}
$totalOps += $count;
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
}