SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Caching Function definitions

    Hello!

    I'm in the process of optimizing a site and am just getting my feet wet with caching. In particular, I'm using Zend_Cache to cache some database results and am hoping to expand what I cache. I have one file, which is approximately 1000 lines long and consists of all of the function definitions for my site. Of course, only a few functions are called in any given script, but for organizational purposes, I thought that this was the way to go. With this in mind I have a couple of questions.

    1) Is there a way to "cache" my function definitions script?
    2) How can I measure what I actually save if I cache something? (in other words, I know that I can measure how long a script takes to run, but what are the other resource expenses?)

    Thank you for answering these questions. There will probably be more of a similar flavor in the next few days.

    -Eric

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kreut View Post
    1) Is there a way to "cache" my function definitions script?
    You could...but it would be pointless...Replace one I/O request for another is not going to save anything. What you truly need is a opcache. An opcache is where PHP parses the PHP source files into byte code and saves those for latter, so it doesn't need to constantly parse your source files. In most cases opcache also saves to memory instead of a hard drive.

    http://www.php.net/manual/en/book.apc.php
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the quick reply!

    And, might you have a suggestion where I can begin to understand benchmarking processes? I feel a little bit like a guy who can drive a car pretty straight without going off the road, but I have no clue how the car works under the hood...

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    If you want to delve into what is happening on your dev machine, then start off with installing the xdebug extension.

    Then move on to generating and analysing cachegrind files - that starts getting you closer to the metal.

    Watch out though, such navel gazing is akin to hanging out your car window watching your tyres go round in order to see if you are wasting fuel, when in fact you could be asking "why am I even going on this journey?"

    EDIT

    re APC : further to logic_earth's reply, APC (when I last used it) came with a utility enabling you to see (and control) which parts of your script are cached, enabling you to see how often they are accessed etc -- this can be very insightful

  5. #5
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you for putting me further on the path AND for the very prudent warning.

    Regards,

    Eric


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
  •