Measuring HTTP requests response time

Needless to say, this topic is complex, first of all because the total response time varies due to network congestion, server load, amount of bytes transfered just to name a few.

Anyway, if you just need to get a raw indication, you could just try out this small script:

function GetRequestTime([string]$url)


  $wc = new-object System.Net.WebClient

  $wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials

  $start = get-date

  $output = $wc.DownloadString($url)

  $span = (get-date).Subtract($start)

  return $span.TotalMilliseconds


function ShootRequests([string]$url, [int]$count)


  $totalTime = 0

  1..$count |% { $totalTime += GetRequestTime($url)}

  return $totalTime / $count


What it does is firing for a request a configurable number of times and return the average response time. Here’s how you may invoke this function:

ShootRequests 50

Just a few notes, though:

  • It does not consider any client-side caching (you could easily overcome this issue by passing some query string parameter that makes the client consider it a brand new resource)
  • It does not download automatically any resource defined in the HTML of the page (i.e. if a page contains img tags that force the browser to download 10MB of content… this script just ignores that)
  • The rendering time is completely transparent too (you may have pages with a small network footprint but with a lot of JS code that slows doen the browser rendering)

CQWP, QueryOverride and filters

You probably know that one of the cool new features of the Content Query Web Part in SharePoint Server 2010 is the support to QueryString and PageField filters.

This was achievable also in MOSS 2007, but you had to rely on Parameter Bindings applied to the CQWP control, which made it a little more complicated since it requires some more knowledge about the “DataView family”.

Just a small note, though: if you keep using the QueryOverride mechanism (i.e., you specify a custom CAML query overwriting the default CQWP behavior), you completely lose the new filters functionality.

More generally, any time you apply some override (Query, View, etc…) the CQWP skips its automatic CAML query/filter/projection generation, and all of the plumbing it’s up to you.

With great power comes a great reponsibility!!