[Pkg-owncloud-commits] [php-sabre-vobject] 295/341: Added another benchmark.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit fa7ca982d14502b926b8b178ea93f4780a69b12d
Author: Evert Pot <me at evertpot.com>
Date: Sat Jul 4 00:56:29 2015 -0400
Added another benchmark.
---
bin/bench_manipulatevcard.php | 67 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/bin/bench_manipulatevcard.php b/bin/bench_manipulatevcard.php
new file mode 100644
index 0000000..454baf3
--- /dev/null
+++ b/bin/bench_manipulatevcard.php
@@ -0,0 +1,67 @@
+<?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();
+
+}
+
+
+
+echo $bench,"\n";
+
+function formatMemory($input) {
+
+ if (strlen($input) > 6) {
+
+ return round($input / (1024 * 1024)) . 'M';
+
+ } else if (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";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list