Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Calculating the time of a LINQ query ?

Calculating the time of a LINQ query ?

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqtutorialquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mohammad Dayyan
    wrote on last edited by
    #1

    Hi guys. I'm gonna calculate a LINQ query time. How can we do it ? Could you guide me ? Thank you

    A A 2 Replies Last reply
    0
    • M Mohammad Dayyan

      Hi guys. I'm gonna calculate a LINQ query time. How can we do it ? Could you guide me ? Thank you

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Just before running the query take the time and store it in datetime variable and then take time after running it. Difference between them is the time it took for query:cool::cool:

      Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
      Create .NET Templates

      M 1 Reply Last reply
      0
      • A Abhishek Sur

        Just before running the query take the time and store it in datetime variable and then take time after running it. Difference between them is the time it took for query:cool::cool:

        Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
        Create .NET Templates

        M Offline
        M Offline
        Mohammad Dayyan
        wrote on last edited by
        #3

        Thanks :)

        E 1 Reply Last reply
        0
        • M Mohammad Dayyan

          Thanks :)

          E Offline
          E Offline
          elektrowolf
          wrote on last edited by
          #4

          But I think LINQ queries are not executed until you somehow access the result like foreaching over it or something like that. So you have to include that into the measurement.

          M 1 Reply Last reply
          0
          • E elektrowolf

            But I think LINQ queries are not executed until you somehow access the result like foreaching over it or something like that. So you have to include that into the measurement.

            M Offline
            M Offline
            Mohammad Dayyan
            wrote on last edited by
            #5

            Do know any references about it ? if so, what's your suggest for estimating a LINQ query time ?

            E 1 Reply Last reply
            0
            • M Mohammad Dayyan

              Do know any references about it ? if so, what's your suggest for estimating a LINQ query time ?

              E Offline
              E Offline
              elektrowolf
              wrote on last edited by
              #6

              Mohammad Dayyan wrote:

              Do know any references about it ?

              http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx[^]

              The moment we entered the foreach loop (that’s important, the SQL was only executed the first time we requested data, until then the query was just kept in-memory as an expression, this is called Deferred Execution), the following SQL Statement was formulated by LINQ and executed on the server.

              Mohammad Dayyan wrote:

              if so, what's your suggest for estimating a LINQ query time ?

              Maybe it's enough to get the first element of the result and do nothing with it to execute the query..

              1 Reply Last reply
              0
              • M Mohammad Dayyan

                Hi guys. I'm gonna calculate a LINQ query time. How can we do it ? Could you guide me ? Thank you

                A Offline
                A Offline
                ABitSmart
                wrote on last edited by
                #7

                If you are interested in digging into the performance of the LINQ query, you can use the CLR profiler. See these interesting links Link 1[^] and Link 2[^]

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups