diff options
author | Wave <wave72@users.noreply.github.com> | 2016-07-22 10:55:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-22 10:55:02 +0200 |
commit | 744ad84714fe0f7a3d90250a4ff02dc4327b9061 (patch) | |
tree | 595fb74ec9ea0bc7130d18bd7993d719a222d343 /vendor/sabre/vobject/bin/bench_manipulatevcard.php | |
parent | c38c79d71c8ef70ef649f83e322f1984b75ee2dd (diff) | |
parent | 7d897a3f03bd57ed556433eb84a41963ba44e02e (diff) | |
download | volse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.tar.gz volse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.tar.bz2 volse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.zip |
Merge pull request #6 from redmatrix/dev
Dev
Diffstat (limited to 'vendor/sabre/vobject/bin/bench_manipulatevcard.php')
-rw-r--r-- | vendor/sabre/vobject/bin/bench_manipulatevcard.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/sabre/vobject/bin/bench_manipulatevcard.php b/vendor/sabre/vobject/bin/bench_manipulatevcard.php new file mode 100644 index 000000000..adc198e9b --- /dev/null +++ b/vendor/sabre/vobject/bin/bench_manipulatevcard.php @@ -0,0 +1,69 @@ +<?php + +include __DIR__ . '/../vendor/autoload.php'; + +if ($argc < 2) { + echo "sabre/vobject ", Sabre\VObject\Version::VERSION, " manipulation benchmark\n"; + echo "\n"; + echo "This script can be used to measure the speed of opening a large amount of\n"; + echo "vcards, making a few alterations and serializing them again.\n"; + echo "system."; + echo "\n"; + echo "Usage: " . $argv[0] . " inputfile.vcf\n"; + die(); +} + +list(, $inputFile) = $argv; + +$input = file_get_contents($inputFile); + +$splitter = new Sabre\VObject\Splitter\VCard($input); + +$bench = new Hoa\Bench\Bench(); + +while (true) { + + $bench->parse->start(); + $vcard = $splitter->getNext(); + $bench->parse->pause(); + + if (!$vcard) break; + + $bench->manipulate->start(); + $vcard->{'X-FOO'} = 'Random new value!'; + $emails = []; + if (isset($vcard->EMAIL)) foreach ($vcard->EMAIL as $email) { + $emails[] = (string)$email; + } + $bench->manipulate->pause(); + + $bench->serialize->start(); + $vcard2 = $vcard->serialize(); + $bench->serialize->pause(); + + $vcard->destroy(); + +} + + + +echo $bench,"\n"; + +function formatMemory($input) { + + if (strlen($input) > 6) { + + return round($input / (1024 * 1024)) . 'M'; + + } elseif (strlen($input) > 3) { + + return round($input / 1024) . 'K'; + + } + +} + +unset($input, $splitter); + +echo "peak memory usage: " . formatMemory(memory_get_peak_usage()), "\n"; +echo "current memory usage: " . formatMemory(memory_get_usage()), "\n"; |