[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Script to check page loading time / page speed

How would I go about making a script that uses the entered url to test the page speed of the home page of that particular domain? The url will be entered on form on a second site. Are there JavaScripts or PHP script in circulation? I prefer to run an independent script and not rely on Yslow as they might block access if too many requests are made from the same location..
0
rhandalthor
Asked:
rhandalthor
  • 6
  • 6
  • 2
  • +2
4 Solutions
 
Leon FesterCommented:
I've always used HTTPWatch for this kind of monitoring
http://www.httpwatch.com/

Have a look at the automation overview, and see if it's something that you can plug into.
http://apihelp.httpwatch.com/#Automation Overview.html
0
 
rhandalthorAuthor Commented:
http://apihelp.httpwatch.com/#Automation won't load in Safari, but did in Chrome. I checked the site and it seems like they only offer browser plugins or plugins running Ruby or C#. I work with PHP/MySQL, JScript, HTML and CSS only..
0
 
remixedcatCommented:
google analytics has some of the features you'd want.

however see this it might interest you:
http://www.askaboutphp.com/44/cacti-using-cacti-to-monitor-web-page-loading-part-1.html
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
remixedcatCommented:
this one is very popular as well!
http://getfirebug.com/network
0
 
rhandalthorAuthor Commented:
Firebug I know, but I did not find an API that will work on a website for that yet. The askaboutphp tip is for showing a page on the server where the script is as far as i can see. I need it to check loading time of external pages and to display it on the same server as the script is at. I am looking tino http://www.showslow.org/Main_Page It only seems to be needing a dedicated server where you can run makes..
0
 
remixedcatCommented:
what about sites like loadimpact or using a remote tool like a load performance tester app?
0
 
leakim971PluritechnicianCommented:
0
 
rhandalthorAuthor Commented:
@ leakim971: How can I use that on a website and let visitors enter an url and check page load speed independantly of what browser or browser extensions they have?
@ remixedcar: http://loadimpact.com/ is neat and what I want to have, but I prefer a script on my site I can use for free instead of using their services for a price. What do you mean by a remote tool? I a visitor to my test site enters an url how can a page speed test can be triggered with a remote tool? What tool?
0
 
leakim971PluritechnicianCommented:
forget my answer...
0
 
remixedcatCommented:
a remote tool like a peice of software on your computer or phone

this site has open source site testing tools:
http://www.opensourcetesting.org/performance.php
0
 
rhandalthorAuthor Commented:
50 possible remote tools. Any PHP/JavaScript based one you can recommend?
0
 
remixedcatCommented:
did you not find one out of that list you can try?
0
 
rhandalthorAuthor Commented:
Thanks for the list. Trying showslow on local server now. Have not tried one of the 50 options yet. Will do later today or this weekend. Familiar with none so will take time...
0
 
remixedcatCommented:
I have only used a couple and they were custom coded and not on that last.
0
 
Ray PaseurCommented:
There is a Firefox plug-in called Firebug, and a Firebug plug-in called YSlow.  VERY helpful.

In PHP I have sometimes used this little stopwatch class to time parts of my scripts or to time the access to web services.

HTH, ~Ray
<?php // RAY_oop_stopwatch.php
error_reporting(E_ALL);


// DEMONSTRATE A SCRIPT TIMER FOR ALL OR PART OF A SCRIPT PHP 5+
// MAN PAGE http://php.net/manual/en/function.microtime.php


class StopWatch
{
    protected $a, $z;
    public function __construct()
    {
        $this->a = array();
        $this->z = array();
    }

    // A METHOD TO CAPTURE A START TIME
    public function start($name='TIMER')
    {
        $this->a[$name] = microtime(TRUE);
    }

    // A METHOD TO CAPTURE AN END TIME
    public function stop($name='ALL')
    {
        if ($name == 'ALL')
        {
            foreach ($this->a as $name => $start_time)
            {
                if (!isset($this->z[$name])) $this->z[$name] = microtime(TRUE);
            }
        }
        else
        {
            $this->z[$name] = microtime(TRUE);
        }
    }

    // A METHOD TO READ OUT THE TIMER(S)
    public function readout($m=1000, $eol=PHP_EOL)
    {
        $str = NULL;
        foreach ($this->a as $name => $start_time)
        {
            $str .= $name;
            if (!isset($this->z[$name]))
            {
                $str .= " IS STILL RUNNING";
            }
            else
            {
                $lapse_time = $this->z[$name] - $start_time;
                $lapse_msec = $lapse_time * $m;
                $lapse_echo = number_format($lapse_msec, 1);
                $str .= " $lapse_echo";
            }
            $str .= $eol;
        }
        return $str;
    }
}


// DEMONSTRATE THE USE -- INSTANTIATE THE STOPWATCH OBJECT
$sw  = new Stopwatch;

// SET STOPWATCH NAMES
$go = 'GOOGLE ONLY';
$gy = 'GOOGLE AND YAHOO!';
$yo = 'YAHOO! ONLY';

// START SOME TIMERS
$sw->start($go);
$sw->start($gy);

// PERFORM SOME ACTIVITY THAT YOU WANT TO TIME
$page = 'http://google.com';
$html = file_get_contents($page);

// STOP ONE OF THE STOPWATCHES AND START THE OTHER
$sw->stop($go);
$sw->start($yo);

// PERFORM SOME OTHER ACTIVITY THAT YOU WANT TO TIME
$page = 'http://yahoo.com';
$html = file_get_contents($page);

// REPORT THE STOPWATCHES CONTENT (TWO WILL BE INCOMPLETE)
echo nl2br($sw->readout());

// STOP ALL OF THE REMAINING STOPWATCHES
$sw->stop();

// REPORT THE STOPWATCHES CONTENT AGAIN
echo nl2br($sw->readout());

Open in new window

0
 
rhandalthorAuthor Commented:
Awarding points for all the shoves in the right direction. Will ask new questions as soon as I have moved further.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 6
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now