Look, here's the way this question breaks down, along with some of my opinions, and some feedback on the flags that were raised.
Closed, or no
First up, let's talk about the merits of the actual question. Let me paraphrase the question as follows:
- I have this code
- it works
- it runs slow the first time it is called.
- subsequent times it runs faster.
- two questions:
- what's the deal with that
- how do I make it consistent
- ( "This is strange. The results do not really vary. The others do. Why?" also "Can someone explain the variation and what is the best way to get a performance as good as possible." )
Now, to be clear, what code is included here? Well, all the code does is wrap an API call in a timer-wrapper. The code that does the work (on the API side) is not included anywhere
The Code works, sure, but, is it your code? (Hint, only the part on this side of the Internet Connection is yours, the rest is Azure's). I.e. This is your code: context.SaveChanges();
So, in my assessment, this code is seeking an explanation of someone else's code because it is seeking an explanation of why the internet, azure, or some other code is running inconsistently.
In the alternative (i.e. in the unlikely event that the question is not about understaning the variance in time....), then there are an additional set of problems:
- the code is not included (the problem is almost certainly in the API side, and that code is not in the question).
- the code almost certainly is not the OP's code - it is service code.
So, I looked at the question and saw a collection of problems, any one of which could be used to close the question.
There is no doubt for me that the question should be closed. The close reason, while only partially related to the real reason, was "good enough".
Fallout
The comments on the post while accurate, mostly, were unhelpful. People were fixating on sub-parts of each other's reasoning, and not communicating effectively. This happens, it's the internet. Saying things often, though, does not make people listen more.
The numerous flags, comments, chat, and so on, for this off-topic question, is .... disconcerting. The close reason was apparently not clear enough, and that probably needs some follow-up, but not part of this question's discussion.
Flags
I declined some flags requesting reopens. There was no reason to reopen the question, and I stand by those declines. My decline reason is/was:
I think the "explaining other people's code" is key here. It is not his code that's inconsistent, but azure.