SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member lans's Avatar
    Join Date
    Sep 2003
    Location
    Netherlands
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can I mesure page perfomance ?

    We all know that there are different ways to implement the same page functionality. Also there can be variations about executing scripts on server or on client side.

    Pls advise me some tool which can mesure execution time of pages, containing scripts in different browsers.

  2. #2
    SitePoint Enthusiast kgish's Avatar
    Join Date
    Dec 2001
    Location
    Gouda, The Netherlands
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am assuming that you want to benchmark the performance by measuring the load time for a given page.

    This can be accomplished fairly easily by using something like the following code.

    Place this right after the body tag:
    Code:
    <body>
    <script type="text/javascript">
    <!--
    var msecs_start = new Date();
    //-->
    </script>
    Then place this as close to the closing body tag as possible:
    Code:
    <script type="text/javascript">
    <!--
    var msecs_stop = new Date();
    var diff = (msecs_stop.getTime() - msecs_start.getTime())/1000;
    document.write('<span class="fright">[<a href="java script:void(0);" title="This page took ' + diff + ' seconds to load.">' + diff + '</a>]</span>');
    //-->
    </script> 
    </body>
    You will then see a number enclosed within bracket which gives you the load time. There are probably more elegant (and more accurate) ways to achieve the same affect, but this should at least give you an idea.

    You can check out this web site for a working example.

    Is this what you meant?
    Kiffin
    Your average future-famous kind of guy...

  3. #3
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Due to differences in parsing and so on between browsers, the above is far from perfect. However, as far as I know, it IS the best technique there is.

    To measure individual functions, the normal approach would be to start a timer, use a loop to run the individual function MANY times (probably at least several thousand), then apply some division to work out the average time.

    Also, bear in mind that, on a Windows NT/2000/XP system, any measured times only have a resolution of about 15 milliseconds. I can't remember the corresponding figure for Win9x (10 ms?). Unix-based systems can usually do it down to individual milliseconds.

  4. #4
    SitePoint Enthusiast kgish's Avatar
    Join Date
    Dec 2001
    Location
    Gouda, The Netherlands
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do not think that one really cares about differences way down to milliseconds, as the accepted norm for browsers nowadays is of the order of seconds really.

    My impression is that the original intention of the question was to find out a rough estimate which could be used as an indication of what functions were hogging up the load time.
    Kiffin
    Your average future-famous kind of guy...

  5. #5
    SitePoint Member lans's Avatar
    Join Date
    Sep 2003
    Location
    Netherlands
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kgish
    My impression is that the original intention of the question was to find out a rough estimate which could be used as an indication of what functions were hogging up the load time.
    You're right, I'm talking not about the downloading time which value mostly depends on files size, cashing etc.

    I'm talking about the time, which is nessesary for browser to display a complete page.

    Because, currently we have really low performance in IE's. js functions work slowly.
    What are the top reasons of such performance ? Can it be huge(js functions work with about 20 div's) amount of objects on the page ?

  6. #6
    SitePoint Enthusiast kgish's Avatar
    Join Date
    Dec 2001
    Location
    Gouda, The Netherlands
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright then, what you further need to do is bracket the suspicious parts of the code and/or functions with the code examples above.

    Find out the part which hogs up the most time. Then further split this section(s) into sub-sections, each time concentrating your effort on the parts with the greatest impact on performance.

    Eventually, through this divide-and-conquer tactics, you should be able to pinpoint the most likely causes of slowness.

    I hope this helps you.
    Kiffin
    Your average future-famous kind of guy...


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
  •