1N/A * weblatency.d - website latency statistics. 1N/A * Written using DTrace (Solaris 10 3/05). 1N/A * $Id: weblatency.d 3 2007-08-01 10:50:08Z brendan $ 1N/A * USAGE: weblatency.d # hit Ctrl-C to end sample 1N/A * See the code below for the "BROWSER" variable, which sets the browser 1N/A * to trace (currently set to "mozilla-bin"). 1N/A * This is written as an experimental tool, and may not work at all with 1N/A * HOST Hostname from URL 1N/A * NUM Number of GETs 1N/A * AVGTIME(ms) Average time for response, ms 1N/A * MAXTIME(ms) Maximum time for response, ms 1N/A * The latency measured here is from the browser sending the GET 1N/A * request to when the browser begins to recieve the response. It 1N/A * is an overall response time for the client, and encompasses 1N/A * connection speed delays, DNS lookups, proxy delays, and web server 1N/A * IDEA: Bryan Cantrill (who wrote an elegant version for Sol 10 update 1) 1N/A * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. 1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License, Version 1.0 only 1N/A * (the "License"). You may not use this file except in compliance 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * Check write fd for socket, not file. 1N/A * 30-Nov-2005 Brendan Gregg Created this. 1N/A * 20-Apr-2006 " " Last update. 1N/A/* browser's execname */ 1N/A/* maximum expected hostname length + "GET http://" */ 1N/A * Trace brower request 1N/A * This is achieved by matching writes for the browser's execname that 1N/A * start with "GET", and then timing from the return of the write to 1N/A * the return of the next read in the same thread. Various stateful flags 1N/A * are used: self->fd, self->read. 1N/A * For performance reasons, I'd like to only process writes that follow a 1N/A * connect(), however this approach fails to process keepalives. 1N/A /* fetch browser request */ 1N/A * This unrolled loop strips down a URL to it's hostname. 1N/A * We ought to use strtok(), but it's not available on Sol 10 3/05, 1N/A * so instead I used dirname(). It's not pretty - it's done so that 1N/A * this works on all Sol 10 versions. 1N/A /* start the timer */ 1N/A/* this one wasn't a GET */ 1N/A * Record host details 1N/A printf(
"\n%-32s %11s\n",
"HOST",
"AVGTIME(ms)");
1N/A printf(
"\n%-32s %11s\n",
"HOST",
"MAXTIME(ms)");