Admun's NUDN

admun

  • San Francisco, CA

Navigation

Navigation

Categories

Benchmarking Nucleus

Here's a cookbook how to setup a simple benchmarking on your blog.

  1. Create a file calls benchmark_setup.txt
  2. <?php
    
    if (!function_exists('getmtime'))
    {
      function getmtime()
      {
        $a = explode (' ',microtime());
        return(double) $a[0] + $a[1];
      }
    }
    
    // For benchmarking
    global $StartTime;
    $StartTime = getmtime();
    
    ?>
    
  3. Add the following lines into index.php, also all FancyURL script files if FancyURL is setup
  4. //setup for benchmarking
    include('./benchmark_setup.txt');
    
  5. Create a file calls benchmark.txt
  6. <?php
    // There are some setup done in index.php.....
    
    if (!function_exists('getmtime'))
    {
      function getmtime()
      {
        $a = explode (' ',microtime());
        return(double) $a[0] + $a[1];
      }
    }
    
      global $StartTime;
      $loadtime = getmtime() - $StartTime;
      echo 'This page takes ' . $loadtime . ' to load<br />';
    ?>
    
  7. Add the following code to the end of your skin
  8. <%phpinclude(/path/to/blog/benchmark.txt)%>
    
Note, there are a lot of factors impacting how fast your blog is loaded (ie network congestion, access to external site, etc).

Credit: Code steal shamelessly from: here

15:10:34 on 07/19/04 by Admun - Category: Developer Notes - tags: none - print

Comments

TeRanEX wrote:

Whoow! That's cool! I have always been wondering how to do this biggrin
Can you also add a method to count how many SQL-queries are executed?

07/19/04 16:09:15

Admun wrote:

Good idea... I will look into it.

07/19/04 16:47:46

Admun wrote:

Took a look, but it seems tricky... still trying..

07/19/04 23:50:08

TeRanEX wrote:

Maybe you can add this item as an article at the NUDN site, so that it will be easier to find it again in a few months? (maybe create a category 'performance' or something like that?).

07/20/04 09:09:36

Admun wrote:

I considered this is an article that NUDN should be linked to (just prefer to write from my NUDN member blog, which the Dev notes/Dev Info/code trace are my contribution to NUDN, General/My wwork are local to my blog), like many others I wrote.

Meanwhile, I don't think we need a performance category just yet.... I think just put in the article section is fine.

BTW, I was suggesting hcgtv to make a script to link other NUDN member site's posts on NUDN. I think we eventually want it. cool

07/20/04 10:20:36

Admun wrote:

Done, I linked all my articles to NUDN. cool

07/20/04 10:38:25

TeRanEX wrote:

just saw it. Nice smile

07/20/04 17:03:17

karma wrote:

To see which queries are executed during a request, I start mysqld using the --log option. Then I browse through the logfile (created in its data dir).

Another option would be to add some code in the sql_query() function (through which most of the Nucleus queries are executed)

07/26/04 11:11:54

Admun wrote:

Thx, karma.

07/26/04 11:14:56

Add Comments