Hicham4
Hicham4

Reputation: 39

Measure loadtime of all pages of an application in C#

I have in several pages, one or more ajax calls or just button-events in the code behind of the pages, and I want a central function which can register or listen to the calls/Events and calculates the load time of the page, and then save those data (page name and event name ) in the database. Has anyone done this before? Please help.

Thanks.

Update

What I'm looking for is a functionality who can save data (page name, userid, application name, load time and current date time) in a database table, every time the page is visited.

Alle pages are inheriting from a basepage. The functionality must be depend of a Boolean setting variable, true = register , false = not. That could be an appsetting in the web.config.

Every tip or trick should be very appreciated.

Thanks.

Upvotes: 1

Views: 46

Answers (1)

Rion Williams
Rion Williams

Reputation: 76547

Consider a Profiler

Have you considered using a profiler like MiniProfiler to handle this? It can be easily added to your application via a NuGet package:

Install-Package MiniProfiler

It can easily be injected into your individual pages, allowing you to see the various load times across your application (i.e. client/AJAX, server, database, etc.) either directly within the UI:

enter image description here

These values can also be persisted to a database of your choosing through a provider (e.g. SQL Server, Raven, etc.)

// Store your profiling data within a database
MiniProfiler.Settings.Storage = new SqlServerStorage(YourConnectionString);

I know folks here at Stack Overflow actually wrote and developed the tool and use it to help make this site run as fast as possible, so if it worked for them, it'll probably work for you.

Upvotes: 2

Related Questions