Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Request timings not very accurate (nearest 15ms) #544

Closed
benaadams opened this issue Jan 1, 2016 · 3 comments
Closed

Request timings not very accurate (nearest 15ms) #544

benaadams opened this issue Jan 1, 2016 · 3 comments
Assignees
Milestone

Comments

@benaadams
Copy link
Contributor

And the server is too fast for it to be that imprecise.

info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/plaintext
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 15ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/favicon.ico
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/plaintext
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/favicon.ico
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/plaintext
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/favicon.ico
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/plaintext
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 15ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/favicon.ico
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/plaintext
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200
info: Microsoft.AspNet.Hosting.Internal.WebApplication[1]
Request starting HTTP/1.1 GET http://localhost:5001/favicon.ico
info: Microsoft.AspNet.Hosting.Internal.WebApplication[2]
Request finished in 0ms 200

@mattnischan
Copy link

in src/Microsoft.AspNet.Hosting/Internal/HostingLoggerExtensions.cs:

public static void RequestFinished(this ILogger logger, HttpContext httpContext, int startTimeInTicks, int currentTick)

in src/Microsoft.AspNet.Hosting/Internal/HostingApplication.cs:

var currentTick = Environment.TickCount;
_logger.RequestFinished(httpContext, context.StartTick, currentTick);

Environment.TickCount is non-high-precision in most platforms, about 15ms resolution, as you're seeing. In some cases DateTime.Ticks can be higher precision, but that is implementation dependent.

Could also burn a Stopwatch here every time, but I don't know if the overhead is worth it. DateTime.Ticks does seem like the better compromise.

@benaadams
Copy link
Contributor Author

@mattnischan added a PR for the improvement #543

@glennc glennc added this to the 1.0.0-rc2 milestone Jan 7, 2016
@glennc glennc added the bug label Jan 7, 2016
@Tratcher Tratcher assigned JunTaoLuo and unassigned Tratcher Jan 13, 2016
@JunTaoLuo
Copy link
Contributor

The PR has been merged. Thanks @benaadams!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants