1

I have a loop that takes about 3 minutes for the first iteration and around 1ms for the rest 99.

I'm trying to figure out if there is a way to get separate profiling data for each loop and how to do it.

I'm very new to profiling so I might be missing something obvious here.

I should note that I know where my bottlenecks are. 2 of my functions take almost 99.9% of the runtime. I'm trying to figure out if it's all in the first loop (an therefore probably some allocation issue) or 'spread' across the execution of the script.

I'm on Windows 10 using Visual Studio 15 (and it's integrated profiler)

dsat
  • 127
  • 1
  • 8
  • Have you read [this page on how to enable line-by-line profiling](https://msdn.microsoft.com/en-us/library/bb385757.aspx) and [this on viewing the results](https://msdn.microsoft.com/en-us/library/ms182372.aspx)? There would seem to be all the data you need easily accessible. What exactly are you having a problem with? (And [this allows you to step through and profile simultaneously](https://www.hanselman.com/blog/HistoricalDebuggingProfilingNewDiagnosticToolsInVisualStudio2015.aspx).) – Ken Y-N May 08 '17 at 00:09
  • Thank you for the links. I know which part of the code is slow . I'm trying to figure if the slowdown is due to a computation error of some weird memory allocation so I can fix it. – dsat May 08 '17 at 08:41
  • The compiler needs to be in release mode for the code I mentioned to work (I forgot to mention that earlier.) – AppWriter May 08 '17 at 18:24
  • It's not that hard. All you gotta do is [*this*](http://stackoverflow.com/a/378024/23771). – Mike Dunlavey May 09 '17 at 23:41

1 Answers1

1
LARGE_INTEGER StartingTime, EndingTime, ElapsedMicroseconds;
QueryPerformanceCounter(&StartingTime);

//code to be profiled

QueryPerformanceCounter(&EndingTime);
ElapsedMicroseconds.QuadPart = EndingTime.QuadPart - StartingTime.QuadPart;

int result[numLoops]
result[0] = ElapsedMicroseconds.QuadPart;

//use result in conjunction with a print function

The compiler must be in release mode for this to work (in Visual Studio at least).

AppWriter
  • 247
  • 2
  • 13
  • I'm getting "No target Architecture" errors when i try to compile. The part that throws the error is this `#elif !defined(RC_INVOKED)` Maybe I should have mentioned it's a console application (an algorithm implementation). – dsat May 08 '17 at 08:58
  • 1
    In case anybody else sees this, you need to add `#include #include ` for this code to compile. – dsat May 10 '17 at 15:49