bench.php
7 months ago
bench_freebusygenerator.php
7 months ago
bench_manipulatevcard.php
7 months ago
fetch_windows_zones.php
1 year ago
generate_vcards
1 year ago
generateicalendardata.php
7 months ago
mergeduplicates.php
7 months ago
rrulebench.php
7 months ago
vobject
1 year ago
bench_freebusygenerator.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | include __DIR__ . '/../vendor/autoload.php'; |
| 4 | if ($argc < 2) { |
| 5 | echo 'sabre/vobject ', \AmeliaVendor\Sabre\VObject\Version::VERSION, " freebusy benchmark\n"; |
| 6 | echo "\n"; |
| 7 | echo "This script can be used to measure the speed of generating a\n"; |
| 8 | echo "free-busy report based on a calendar.\n"; |
| 9 | echo "\n"; |
| 10 | echo "The process will be repeated 100 times to get accurate stats\n"; |
| 11 | echo "\n"; |
| 12 | echo 'Usage: ' . $argv[0] . " inputfile.ics\n"; |
| 13 | exit; |
| 14 | } |
| 15 | list(, $inputFile) = $argv; |
| 16 | $bench = new Hoa\Bench\Bench(); |
| 17 | $bench->parse->start(); |
| 18 | $vcal = \AmeliaVendor\Sabre\VObject\Reader::read(fopen($inputFile, 'r')); |
| 19 | $bench->parse->stop(); |
| 20 | $repeat = 100; |
| 21 | $start = new \DateTime('2000-01-01'); |
| 22 | $end = new \DateTime('2020-01-01'); |
| 23 | $timeZone = new \DateTimeZone('America/Toronto'); |
| 24 | $bench->fb->start(); |
| 25 | for ($i = 0; $i < $repeat; ++$i) { |
| 26 | $fb = new \AmeliaVendor\Sabre\VObject\FreeBusyGenerator($start, $end, $vcal, $timeZone); |
| 27 | $results = $fb->getResult(); |
| 28 | } |
| 29 | $bench->fb->stop(); |
| 30 | echo $bench, "\n"; |
| 31 | function formatMemory($input) |
| 32 | { |
| 33 | if (strlen($input) > 6) { |
| 34 | return round($input / (1024 * 1024)) . 'M'; |
| 35 | } elseif (strlen($input) > 3) { |
| 36 | return round($input / 1024) . 'K'; |
| 37 | } |
| 38 | } |
| 39 | unset($input, $splitter); |
| 40 | echo 'peak memory usage: ' . formatMemory(memory_get_peak_usage()), "\n"; |
| 41 | echo 'current memory usage: ' . formatMemory(memory_get_usage()), "\n"; |