-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.php
More file actions
68 lines (58 loc) · 1.82 KB
/
benchmark.php
File metadata and controls
68 lines (58 loc) · 1.82 KB
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
<?php
/******************************************************************************
* An iterator interface over the Leagues flysystem.
* Copyright (c) 2021, 2015 Richard Klees <richard.klees@rwth-aachen.de>
*
* This software is licensed under GPLv3. You should have received
* a copy of the along with the code.
*/
require_once("tests/autoloader.php");
$adapter = new \League\Flysystem\Adapter\Local(__DIR__);
$flysystem = new \League\Flysystem\Filesystem($adapter);
$flightcontrol_strict = new \Lechimp\Flightcontrol\Flightcontrol($flysystem);
$dir = $flightcontrol_strict->directory("");
$runs = 100;
$count = 0;
$start = microtime(true);
for ($i = 0; $i < $runs; $i++) {
$count = 0;
$dir
->iterateOn()
->iterateOn()
->with(function ($obj) use (&$count) {
$count += 1;
});
}
$end = microtime(true);
$diff = $end - $start;
echo "Flightcontrol: " . sprintf("%10.4f", $diff) . " s (and counted $count)\n";
$start = microtime(true);
for ($i = 0; $i < $runs; $i++) {
$count = 0;
foreach ($flysystem->listContents() as $dir) {
foreach ($flysystem->listContents($dir["path"]) as $dir2) {
$count += 1;
}
}
}
$end = microtime(true);
$diff = $end - $start;
echo "Flysystem: " . sprintf("%10.4f", $diff) . " s (and counted $count)\n";
$start = microtime(true);
for ($i = 0; $i < $runs; $i++) {
$count = 0;
foreach (scandir(".") as $dir) {
if (!is_dir($dir) or $dir == "." or $dir == "..") {
continue;
}
foreach (scandir("./$dir") as $dir2) {
if ($dir2 == "." or $dir2 == "..") {
continue;
}
$count += 1;
}
}
}
$end = microtime(true);
$diff = $end - $start;
echo "scandir: " . sprintf("%10.4f", $diff) . " s (and counted $count)\n";