Page 4 of 4 FirstFirst ... 234
Results 31 to 32 of 32

Thread: images/directory listing script

  1. #31
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Also, I think that:
    "stuff\n";
    would be faster than:
    'stuff'."\n";

    (Though yes, 'stuff' is faster than "stuff")
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #32
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <?php
      function avg($arr) {
        $total = 0;
        for($i = 0; $i < count($arr); ++$i)
          $total += $arr[$i];
        return $total / count($arr);
      }
    
      $times1 = array();
      $times2 = array();
      for($i = 0; $i < 10000; ++$i) {
        $s = microtime();
        'Hello' . "\n";
        array_push($times1, microtime() - $s);
        $s = microtime();
        "Hello\n";
        array_push($times2, microtime() - $s);
      }
    
      echo 'Average for single/double concatenation: ' . avg($times1) . "\n" .
        'Average for only double: ' . avg($times2) . "\n";
    ?>
    Output:
    Code:
    Average for single/double concatenation: 1.7569E-06
    Average for only double: 1.6627E-06
    It is.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •