From 0b77810a40f612827ad7ef0404782e802ad50c26 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Wed, 22 May 2013 00:31:55 +0400 Subject: [PATCH] System.Diagnostics.Stopwatch is used instead of DateTime --- FLocal.IISHandler/MainHandler.cs | 7 ++++--- FLocal.IISHandler/handlers/AbstractGetHandler.cs | 5 +++-- FLocal.IISHandler/handlers/request/AbstractPostHandler.cs | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/FLocal.IISHandler/MainHandler.cs b/FLocal.IISHandler/MainHandler.cs index ee6cb50..7148c60 100644 --- a/FLocal.IISHandler/MainHandler.cs +++ b/FLocal.IISHandler/MainHandler.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Web; @@ -46,14 +47,14 @@ namespace FLocal.IISHandler { public void ProcessRequest(HttpContext context) { Initializer.instance.Initialize(); - DateTime start = DateTime.Now; + Stopwatch st = Stopwatch.StartNew(); int requestNumber = counter.GetCurrentValueAndIncrement(); try { Config.instance.Logger.Log("Began serving request #" + requestNumber + ": " + context.Request.Url.AbsoluteUri); this.doProcessRequest(context); - Config.instance.Logger.Log("Done serving request #" + requestNumber + "; " + (DateTime.Now-start).TotalSeconds + " seconds spent"); + Config.instance.Logger.Log("Done serving request #" + requestNumber + "; " + st.ElapsedMilliseconds + " ms spent"); } catch(RedirectException e) { - Config.instance.Logger.Log("Done serving request #" + requestNumber + "; " + (DateTime.Now-start).TotalSeconds + " seconds spent (redirected)"); + Config.instance.Logger.Log("Done serving request #" + requestNumber + "; " + st.ElapsedMilliseconds + " ms spent (redirected)"); context.Response.Redirect(e.newUrl); } } diff --git a/FLocal.IISHandler/handlers/AbstractGetHandler.cs b/FLocal.IISHandler/handlers/AbstractGetHandler.cs index d86aa4e..1065d87 100644 --- a/FLocal.IISHandler/handlers/AbstractGetHandler.cs +++ b/FLocal.IISHandler/handlers/AbstractGetHandler.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Xml.Linq; @@ -38,14 +39,14 @@ namespace FLocal.IISHandler.handlers { } private XDocument getData(WebContext context) { - DateTime start = DateTime.Now; + var st = Stopwatch.StartNew(); var specificData = this.getSpecificData(context); var commonData = this.getCommonData(context); return new XDocument( new XElement("root", specificData, commonData, - new XElement("processingTime", (DateTime.Now-start).TotalSeconds) + new XElement("processingTime", st.ElapsedMilliseconds) ) ); } diff --git a/FLocal.IISHandler/handlers/request/AbstractPostHandler.cs b/FLocal.IISHandler/handlers/request/AbstractPostHandler.cs index b1cd331..d17ff37 100644 --- a/FLocal.IISHandler/handlers/request/AbstractPostHandler.cs +++ b/FLocal.IISHandler/handlers/request/AbstractPostHandler.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Xml.Linq; @@ -41,14 +42,14 @@ namespace FLocal.IISHandler.handlers.request { } private XDocument getData(WebContext context) { - DateTime start = DateTime.Now; + var st = Stopwatch.StartNew(); var specificData = this.Do(context); var commonData = this.getCommonData(context); return new XDocument( new XElement("root", specificData, commonData, - new XElement("processingTime", (DateTime.Now-start).TotalSeconds) + new XElement("processingTime", st.ElapsedMilliseconds) ) ); }