How to calculate the time of a LINQ query?

Asked

Viewed 65 times

4

I have a table with +- 900mil records. I make some queries using clauses where and I want to see the time difference between them.

How do I show time in one label at the end of the consultation?

1 answer

5


You can use Miniprofiler:

using StackExchange.Profiling;

var profiler = MiniProfiler.Current;
using (profiler.Step("Minha query"))
{
    var alguma coisa = /* Coloque sua consulta LINQ aqui */
}

Miniprofiler works with several templates. Just choose what is part of your application and use.

  • 1

    For those who use Visual Studio, already have own Analyze Performance.

  • 2

    Miniprofiler can be used in any type of application. Just check the link I placed and check if there is any kind of specific configuration. The question explains that the result should exit in label, so it’s not using Visual Studio functionality.

  • what does the line mean using (profiler.Step("Minha query")) since the consultation will be below?

  • 1

    It marks everything inside the block as "My query". What Miniprofiler returns to you is the total time of everything you’ve put inside this block.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.