ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
bench_manipulatevcard.php
Go to the documentation of this file.
1 <?php
2 
3 include __DIR__ . '/../vendor/autoload.php';
4 
5 if ($argc < 2) {
6  echo "sabre/vobject ", Sabre\VObject\Version::VERSION, " manipulation benchmark\n";
7  echo "\n";
8  echo "This script can be used to measure the speed of opening a large amount of\n";
9  echo "vcards, making a few alterations and serializing them again.\n";
10  echo "system.";
11  echo "\n";
12  echo "Usage: " . $argv[0] . " inputfile.vcf\n";
13  die();
14 }
15 
16 list(, $inputFile) = $argv;
17 
18 $input = file_get_contents($inputFile);
19 
21 
22 $bench = new Hoa\Bench\Bench();
23 
24 while (true) {
25 
26  $bench->parse->start();
27  $vcard = $splitter->getNext();
28  $bench->parse->pause();
29 
30  if (!$vcard) break;
31 
32  $bench->manipulate->start();
33  $vcard->{'X-FOO'} = 'Random new value!';
34  $emails = [];
35  if (isset($vcard->EMAIL)) foreach ($vcard->EMAIL as $email) {
36  $emails[] = (string)$email;
37  }
38  $bench->manipulate->pause();
39 
40  $bench->serialize->start();
41  $vcard2 = $vcard->serialize();
42  $bench->serialize->pause();
43 
44  $vcard->destroy();
45 
46 }
47 
48 
49 
50 echo $bench,"\n";
51 
52 function formatMemory($input) {
53 
54  if (strlen($input) > 6) {
55 
56  return round($input / (1024 * 1024)) . 'M';
57 
58  } elseif (strlen($input) > 3) {
59 
60  return round($input / 1024) . 'K';
61 
62  }
63 
64 }
65 
66 unset($input, $splitter);
67 
68 echo "peak memory usage: " . formatMemory(memory_get_peak_usage()), "\n";
69 echo "current memory usage: " . formatMemory(memory_get_usage()), "\n";
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
global $argv
Definition: svg-scanner.php:41
const VERSION
Full version number.
Definition: Version.php:17
formatMemory($input)
The VCard component.
Definition: VCard.php:18