Note that there are some explanatory texts on larger screens.

plurals
  1. POchecking speed and memory size of a c# method
    primarykey
    data
    text
    <p>Does anyone see any issues with this basic test?</p> <pre><code>var GC_MemoryStart = System.GC.GetTotalMemory(true); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); var test = new InquiryServiceTypeData().GetActive(true); stopWatch.Stop(); var GC_MemoryEnd = System.GC.GetTotalMemory(true); arrayTotal[i] = (stopWatch.ElapsedTicks * 1000.0) / Stopwatch.Frequency; size[i] = GC_MemoryEnd - GC_MemoryStart; </code></pre> <p>Just trying to get a general estimate of how long the method takes to run and how much memory in the heap it uses. </p> <p>Aka, some of the tests use dataset/datatables, some use lists, and some use both. </p> <p>This code is thrown in a loop so that I can change the number of iterations. I then display the average time each method takes and the average size.</p> <p>EDIT: The GetActive method accesses a database and returns data. The different methods that I'm measuring process the data returned in a different way. </p> <p>Method 1 - Returns a data into a dataset and then converts to an object list. Method 2 - Returns a datareader and converts to an object list. Method 3 - A merging of the first 2 methods.</p> <p>The reason for the code is to settle a disagrement with a coworker. He thinks my code was crap because the datareader and converting to an object list has a ton of 'new' statements which places a load on the heap. I argue that he's wrong. So I want to show him metrics because he didn't listen to any of my logical statements. You can't argue with numbers though. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload