Boot time counter

    Colleagues, friends, and just habraly people. A week ago, a code for the download counter was uploaded to Web Optimizator (a little more detailed information on measuring page load time can be found in the articles about analysis of download speed and overclocking of an online store ).

    Now, each (not) high-loaded project can afford to see what the actual speed of loading its pages for end users. The distribution chart of webo.in users by the load time of this site from them. An example of current statistics and obtaining code is organized here http://webo.in/my/action/counter/?url=webo.in

    Web Optimizator Download Time





    So far, everything is in a fairly test mode (all statistics are collected, but so far it is displayed only in a general form). To view you need to register.

    What is already there:
    1. Data collection :)
    2. Displaying a graph of the distribution of the number of users by load time
    3. Displaying the average load time
    4. Displaying the number of users who load the page up to 4 seconds inclusive (some characteristic parameter for optimization).
    5. Ability to set the date range.
    6. Ability to display data on individual browsers and families (18 in total).

    What is planned to be added in just a couple of days:
    1. Closing statistics for an individual site
    2. Slice download time for individual browsers (now in the database 17 main)
    3. Adding any slices to the fastest / slowest pages and viewing statistics for individual pages.

    A few thousand hits a day for an average blog / store service will survive without difficulty. If there will be interruptions in the processing of statistics (now the logs are driven into the database every ten minutes) - I will shake the main "heavyweights" :) For the server is not rubber.

    What issues have not been resolved:
    1. In what form is it most convenient to display a list of pages by loading time? Page by table with the ability to sort or invented some other more convenient mode for this?
    2. If someone has ideas on how to track user re-entry (when statics can be taken from the cache) on the same page without setting a cookie- I will be grateful. I don’t really want to drive cookies to the statistics server.
    3. Yes, how to disable Last-Modifiednginx for a picture? Headings want to be cut to a minimum.

    Naturally, any comments are welcome. The code and available functionality can be obtained at
    http://webo.in/my/action/counter/

    Principle of operation


    JavaScript adds an window.onloadexternal image call from the statistics server with the main parameters to the event . window.onload only works when the entire page is loaded in the browser. There shouldn’t be any conflicts with other handlers, the code is something like this (formatted a bit to improve understanding, more fully thought out in a note on organizing statistics counters ):

    var __WEBO_UA = 0;
    var __WEBO_START = new Date ();
    (function () {
    	window [/ * @ cc_on! @ * / 0? 'attachEvent': 'addEventListener'] (/ * @ cc_on 'on' + @ * / 'load',
    		function () {
    			new Image (1,1) .src = "http://s.webo.name/0.gif?" +
    			__WEBO_UA + ";" +
    			((new Date ()) -__ WEBO_START) + ";" +
    			escape (location.href) + "; 0;" +
    			Math.random ()
    		}, false)
    } ());

    Naturally, if you want to measure the initial appearance of the page in the browser, you can hang it on a slightly earlier event - the combined onDOMReady , but this is already a matter of taste. The current version of the counter does not affect performance at all (more precisely, the effect is much less than all almost all current Runet counters).

    The idea is not new, but so far I have not seen a public implementation anywhere. In general, IMHO, this should be a convenient tool for "point-by-point" profiling of website performance - after all, the code can be installed on only one page, for example.

    As usual, I am waiting for comments and fresh ideas: an example of the output of statistics for webo.in

    PS I hope that the counter effect does not put a habraeffect :)

    Also popular now: