System.Diagnostics.Stopwatch is used instead of DateTime

main
Inga 🏳‍🌈 11 years ago
parent 2c65eb4bae
commit 0b77810a40
  1. 7
      FLocal.IISHandler/MainHandler.cs
  2. 5
      FLocal.IISHandler/handlers/AbstractGetHandler.cs
  3. 5
      FLocal.IISHandler/handlers/request/AbstractPostHandler.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Web; using System.Web;
@ -46,14 +47,14 @@ namespace FLocal.IISHandler {
public void ProcessRequest(HttpContext context) { public void ProcessRequest(HttpContext context) {
Initializer.instance.Initialize(); Initializer.instance.Initialize();
DateTime start = DateTime.Now; Stopwatch st = Stopwatch.StartNew();
int requestNumber = counter.GetCurrentValueAndIncrement(); int requestNumber = counter.GetCurrentValueAndIncrement();
try { try {
Config.instance.Logger.Log("Began serving request #" + requestNumber + ": " + context.Request.Url.AbsoluteUri); Config.instance.Logger.Log("Began serving request #" + requestNumber + ": " + context.Request.Url.AbsoluteUri);
this.doProcessRequest(context); 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) { } 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); context.Response.Redirect(e.newUrl);
} }
} }

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
@ -38,14 +39,14 @@ namespace FLocal.IISHandler.handlers {
} }
private XDocument getData(WebContext context) { private XDocument getData(WebContext context) {
DateTime start = DateTime.Now; var st = Stopwatch.StartNew();
var specificData = this.getSpecificData(context); var specificData = this.getSpecificData(context);
var commonData = this.getCommonData(context); var commonData = this.getCommonData(context);
return new XDocument( return new XDocument(
new XElement("root", new XElement("root",
specificData, specificData,
commonData, commonData,
new XElement("processingTime", (DateTime.Now-start).TotalSeconds) new XElement("processingTime", st.ElapsedMilliseconds)
) )
); );
} }

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
@ -41,14 +42,14 @@ namespace FLocal.IISHandler.handlers.request {
} }
private XDocument getData(WebContext context) { private XDocument getData(WebContext context) {
DateTime start = DateTime.Now; var st = Stopwatch.StartNew();
var specificData = this.Do(context); var specificData = this.Do(context);
var commonData = this.getCommonData(context); var commonData = this.getCommonData(context);
return new XDocument( return new XDocument(
new XElement("root", new XElement("root",
specificData, specificData,
commonData, commonData,
new XElement("processingTime", (DateTime.Now-start).TotalSeconds) new XElement("processingTime", st.ElapsedMilliseconds)
) )
); );
} }

Loading…
Cancel
Save