Since version 2018R2 we have StartProfiling and StopProfiling
I could not find any documentation pointing out how to use it, but I give it a try:

[code]Dim a As Int64
For x As Integer = 0 To 1000
a = a + x


I sometimes use the Profile Code option in the Project menu, which is not very practical when you have a large project, so I was happy which the extension being announced.
But now, how is it expected to work. ?

@Paul Lefebvre : profiling could be an interesting subject for a webinar, I think.

If your only concern is to measure the time a loop takes to execute, you really do not need any StartProfiling/EndProfiling (which I suspect are really tied to the “Profile project” thing). You can use Ticks() or Microseconds() to do so

You literally only have to call StartProfiling and StopProfiling and activate Profile Code. You run your app with the code. After quitting you will see the profile in the Navigator.

Thanks Bea, I didn’t know that… but I am still loyal to RS 2012r2.1to develop apps, even if it is outdated

If you want to profile just a section of your code, app StopProfiling to App.Open, then surround the section(s) you want to profile with StartProfiling/StopProfiling. To get the profile at all, you still need to turn it on before running or compiling your app.

Understood .
But, if you put this code

Dim a As Int64 StartProfiling For x As Integer = 0 To 1000 a = a + x Next StopProfiling

in a action-event of a button, you will notice that it gets only profiled once, no matter how often you press the button to run this code.

I think that’s because the “call” to the method only happened once while profiling was on. The remaining times, it was already in the method when profiling was toggled.

Move the For loop to its own method instead and see what happens: