GetTickCount() to measure efficient code - page 2

 
Hi Mod,
I just have got a message that you removed my post:

"System
Your post "1. Using code..." has been removed from topic "GetTickCount() to measure efficient code" by a moderator. Reason: Please don't answer a MQL4 question with MQL5 functionality. "GetMicrosecondCount" is not available in MQL4."


GetMicrosecondCount() exists in both MQL4 & 5. Check it out HERE.


1. Using code profiler it is the best you can do here.
2. Also you can use  GetMicrosecondCount() instead of GetTickCount();

sometimes I use my own stopwatch, but mostly I use the profiler

struct StopWatch
{
   StopWatch(){}
   ~StopWatch(){}
   
   ulong ElapsedMicroseconds;
   double ElapsedMilliseconds;
   double ElapsedSeconds;
   
   void Start()
   {
      Start_Microseconds = GetMicrosecondCount();
      Reset();
   }
   void Stop(string message = "")
   {
      End_Microseconds = GetMicrosecondCount();
      if(Start_Microseconds > End_Microseconds) { Print("WARNING! StopWatch: Start > end"); }
      
      ElapsedMicroseconds = End_Microseconds - Start_Microseconds;
      ElapsedMilliseconds = (ElapsedMicroseconds/1000.0);
      ElapsedSeconds      = (ElapsedMicroseconds/1000000.0);
      
      PrintElapsedTime(message);
   }
   
   private:
   ulong Start_Microseconds;
   ulong End_Microseconds;
   void PrintElapsedTime(string message)
   {
      string result;
      StringConcatenate(result, message,": ",ElapsedMicroseconds, "mcs ", ElapsedMilliseconds, "ms ", ElapsedSeconds, "s");
      Print(result);
   }
   void Reset()
   {
      End_Microseconds    = 0;
      ElapsedMicroseconds = 0;
      ElapsedMilliseconds = 0;
      ElapsedSeconds      = 0;
   }
};
Ex. using:
StopWatch sw();

sw.Start();
// response parsing code . . .
sw.Stop("response parsing");
GetMicrosecondCount - Common Functions - MQL4 Reference
GetMicrosecondCount - Common Functions - MQL4 Reference
  • docs.mql4.com
GetMicrosecondCount - Common Functions - MQL4 Reference
[Deleted]  
@Vitaliy Oleksyn #:
I just have got a message that you removed my post:

"System
Your post "1. Using code..." has been removed from topic "GetTickCount() to measure efficient code" by a moderator. Reason: Please don't answer a MQL4 question with MQL5 functionality. "GetMicrosecondCount" is not available in MQL4."


GetMicrosecondCount() exists in both MQL4 & 5. Check it out HERE.


I was the one who removed your post. I did a search on the List of MQL4 Functions and the function did not apear there. That is why I removed it.

However, it seems that it is supported by MQL4, but is not listed in the link I just gave.

My apologies! I have restored your previous post and merged it with your most recent one (see above).

Again, my apologies.

List of MQL4 Functions - MQL4 Reference
List of MQL4 Functions - MQL4 Reference
  • docs.mql4.com
List of MQL4 Functions - MQL4 Reference