diff --git a/Teknik/Global.asax.cs b/Teknik/Global.asax.cs index e00f0d4..272ceba 100644 --- a/Teknik/Global.asax.cs +++ b/Teknik/Global.asax.cs @@ -53,7 +53,7 @@ namespace Teknik TimeSpan ts = stopwatch.Elapsed; string elapsedTime = String.Format("{0} seconds", ts.TotalSeconds); - context.Response.AddHeader("LoadTime", elapsedTime); + context.Response.AppendHeader("GenerationTime", elapsedTime); } protected void Application_PostAuthenticateRequest(Object sender, EventArgs e) diff --git a/Teknik/Modules/PerformanceMonitorModule.cs b/Teknik/Modules/PerformanceMonitorModule.cs new file mode 100644 index 0000000..caf4e4a --- /dev/null +++ b/Teknik/Modules/PerformanceMonitorModule.cs @@ -0,0 +1,48 @@ +´╗┐using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web; + +namespace Teknik.Modules +{ + public class PerformanceMonitorModule : IHttpModule + { + public void Dispose() { /* Nothing to do */ } + public void Init(HttpApplication context) + { + context.PreRequestHandlerExecute += delegate (object sender, EventArgs e) + { + HttpContext requestContext = ((HttpApplication)sender).Context; + Stopwatch timer = new Stopwatch(); + requestContext.Items["Timer"] = timer; + timer.Start(); + }; + context.PostRequestHandlerExecute += delegate (object sender, EventArgs e) + { + HttpContext requestContext = ((HttpApplication)sender).Context; + + Stopwatch timer = (Stopwatch)requestContext.Items["Timer"]; + timer.Stop(); + // Don't interfere with non-HTML responses + + if (requestContext.Response.ContentType == "text/html" || + requestContext.Response.ContentType == "application/json") + { + + Uri requestUrl = requestContext.Request.Url; + double ms = (double)timer.ElapsedMilliseconds; + string result = string.Format("{0:F0}", ms); + + requestContext.Response.Write( + ""); + } + }; + } + } +} diff --git a/Teknik/Scripts/Common.js b/Teknik/Scripts/Common.js index 66c4e08..112a162 100644 --- a/Teknik/Scripts/Common.js +++ b/Teknik/Scripts/Common.js @@ -83,4 +83,27 @@ String.prototype.hashCode = function () { hash |= 0; // Convert to 32bit integer } return hash; -}; \ No newline at end of file +}; + +/***************************** TIMER Page Load *******************************/ +var loopTime; +var startTime = new Date(); +var pageGenerationTime = "0.0"; + +function pageloadTimerCount() { + loopTime = setTimeout("pageloadTimerCount()", 100); +} + +function pageloadDoTimer() { + pageloadTimerCount(); +} + +function pageloadStopTimer() { + var timeMs = Math.floor((new Date() - startTime)); + + $('#loadtime').html(timeMs); + $('#generatetime').html(pageGenerationTime); + $('#pagetime').show(); + + clearTimeout(loopTime); +} \ No newline at end of file diff --git a/Teknik/Teknik.csproj b/Teknik/Teknik.csproj index ac71b6e..f4c455d 100644 --- a/Teknik/Teknik.csproj +++ b/Teknik/Teknik.csproj @@ -194,6 +194,7 @@ + diff --git a/Teknik/Views/Shared/_Footer.cshtml b/Teknik/Views/Shared/_Footer.cshtml index 6b61cbd..8716f94 100644 --- a/Teknik/Views/Shared/_Footer.cshtml +++ b/Teknik/Views/Shared/_Footer.cshtml @@ -8,10 +8,20 @@ FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fileVersionInfo.ProductVersion; } -

- © Teknik 2013-2016 | Privacy | Transparency | Server -
- @string.Format("{0}", version) -

+
+
+ © Teknik 2013-2016 | Privacy | Transparency | Server +
+
+ +
+
+
+
+ Version: @string.Format("{0}", version) +
+
diff --git a/Teknik/Views/Shared/_Layout.cshtml b/Teknik/Views/Shared/_Layout.cshtml index f0e8e65..0e342ea 100644 --- a/Teknik/Views/Shared/_Layout.cshtml +++ b/Teknik/Views/Shared/_Layout.cshtml @@ -3,6 +3,9 @@ + @@ -47,5 +50,9 @@ @RenderBody() @Html.Partial("_Footer") + + diff --git a/Teknik/Web.config b/Teknik/Web.config index edd3aec..3bb6404 100644 --- a/Teknik/Web.config +++ b/Teknik/Web.config @@ -43,6 +43,7 @@ +