• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

.NET API

Performance Monitoring

In this era of high speed broadband and the abundance of libraries that simplify Web development, it is very easy to make the mistake of not taking bandwidth into account. Despite the spread of 4G networks and even the plans for 5G networks, the reality is such, that most mobile operators are struggling to consistently deliver a reliable 3G service in all areas.

Customers using our Enterprise data file could benefit from the performance monitoring JavaScript snippet, built into the data file, which allows the detection of slow connections. Detecting a slow connection allows you to send a response with only the most essential HTML page elements included so that no customer is left behind, regardless of the quality of their internet connection.

Using Performance Monitoring

When used with the Enterprise version of the data set the API will return information about the performance of the connection and response times via the Context. The values change for every page request and will only start to appear after the 2nd request to the web server. The following properties are available:

Property Type Description
51D_LastResponseTime TimeSpan the time taken for the web page to start rendering after the user initiated the request.
51D_LastCompletionTime TimeSpan the time taken for the web page to complete rendering after the user initiated the request.
51D_AverageResponseTime TimeSpan the average time taken for the page to start rendering after the user initiated the request during the previous 5 minutes.
51D_AverageCompletionTime TimeSpan the average time taken for the page to complete rendering after the user initiated the request during the previous 5 minutes.
51D_AverageBandwidth Integer the effective average bandwidth of the connection as measured by the amount of HTML data sent and received. The value will vary from a network level inspection as it does not include the TCP or HTTP overhead. It should be used as a guide to the available effective bandwidth. The time values are of more practical use to developers.

The functionality will be available when the JavascriptBandwidth property is available for the device. The following code shows how to output the parameters:

<% if (Request.Browser["JavascriptBandwidth"] != null)
       { %>
        <div style="clear: both">
            <p>Last Response Time: <% =String.Format("{0:ss\\.fff}s", Context.Items["51D_LastResponseTime"])%></p>
            <p>Last Completion Time: <% =String.Format("{0:ss\\.fff}s", Context.Items["51D_LastCompletionTime"])%></p>
            <p>Average Response Time: <% =String.Format("{0:ss\\.fff}s", Context.Items["51D_AverageResponseTime"])%></p>
            <p>Average Completion Time: <% =String.Format("{0:ss\\.fff}s", Context.Items["51D_AverageCompletionTime"])%></p>
            <p>Average Bandwidth: <% =String.Format("{0:n0}bps", Context.Items["51D_AverageBandwidth"])%></p>
        </div>
    <% } %>

ASP Developers

When used with ASP the previous examples work unaltered. The necessary javascript includes are inserted automatically into the page.

MVC

The necessary javascript includes and script need to be added into the page by the developer. The following needs to be added to the header of the view:

<script src="/51Degrees.core.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
new FODBW();
//]]>
</script>