Advertisement
dead__

Untitled

Jun 20th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.     $repetitions = 2000000;
  3.    
  4.     $item = 'Hallo';
  5.     $pow = 'was';
  6.     $sit = 'geht?';
  7.    
  8.     $test = '';
  9.    
  10.     $time = microtime(true);
  11.     for($i=0;$i<$repetitions;$i++)
  12.         $test = "{$item} {$pow} {$sit}";
  13.     echo '1. Curly Braces: ' . (microtime(true)-$time) . '<br>';
  14.    
  15.     $time = microtime(true);
  16.     for($i=0;$i<$repetitions;$i++)
  17.         $test = "$item $pow $sit";
  18.     echo '2. Inline: ' . (microtime(true)-$time) . '<br>';
  19.    
  20.     $time = microtime(true);
  21.     for($i=0;$i<$repetitions;$i++)
  22.         $test = $item . " " . $pow . " " . $sit;
  23.     echo '3. Concatenate Doublequote: ' . (microtime(true)-$time) . '<br>';
  24.    
  25.     $time = microtime(true);
  26.     for($i=0;$i<$repetitions;$i++)
  27.         $test = $item . ' ' . $pow . ' ' . $sit;
  28.     echo '4. Concatenate Singlequote: ' . (microtime(true)-$time);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement