-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
io.bench.php
54 lines (52 loc) · 1.6 KB
/
io.bench.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
<?php
return [
'file_read' => function($multiplier = 1, $count = 1000) {
file_put_contents('test.txt', "test");
$count = $count * $multiplier;
for ($i = 0; $i < $count; $i++) {
file_get_contents('test.txt');
}
unlink('test.txt');
return $i;
},
'file_write' => function($multiplier = 1, $count = 1000) {
$count = $count * $multiplier;
for ($i = 0; $i < $count; $i++) {
file_put_contents('test.txt', "test $i");
}
unlink('test.txt');
return $i;
},
'file_zip' => function($multiplier = 1, $count = 1000) {
file_put_contents('test.txt', "test");
$count = $count * $multiplier;
for ($i = 0; $i < $count; $i++) {
$zip = new ZipArchive();
$zip->open('test.zip', ZipArchive::CREATE);
$zip->addFile('test.txt');
$zip->close();
}
unlink('test.txt');
unlink('test.zip');
return $i;
},
'file_unzip' => function($multiplier = 1, $count = 1000) {
file_put_contents('test.txt', "test");
$zip = new ZipArchive();
$zip->open('test.zip', ZipArchive::CREATE);
$zip->addFile('test.txt');
$zip->close();
$count = $count * $multiplier;
for ($i = 0; $i < $count; $i++) {
$zip = new ZipArchive();
$zip->open('test.zip');
$zip->extractTo('test');
$zip->close();
}
unlink('test.txt');
unlink('test.zip');
unlink('test/test.txt');
rmdir('test');
return $i;
},
];