GetMicrosecondCount

Overview

The GetMicrosecondCount() function returns the number of microseconds that have elapsed since the start of the MQL program.

Signature

ulong GetMicrosecondCount();

Return Value

  • **ulong**: The number of microseconds elapsed since the MQL program started.
  • Example

    //+------------------------------------------------------------------+
    //| Script program start function                                    |
    //+------------------------------------------------------------------+
    void OnStart()
      {
       uint   ui=0,ui_max=0,ui_min=INT_MAX;
       ulong  ul=0,ul_max=0,ul_min=INT_MAX;
    //--- number of measurements
       for(int count=0;count<1000;count++)
         {
          uint   ui_res=0;
          ulong  ul_res=0;
          //--- 
          for(int n=0;n<2;n++)
            {
             //--- select measurement type
             if(n==0) ui=GetTickCount();
             else      ul=GetMicrosecondCount();
             //--- execute code  
             Test(); // Assuming Test() is defined elsewhere
             //--- add measurement result (depending on type)
             if(n==0) ui_res+=GetTickCount()-ui;
             else      ul_res+=GetMicrosecondCount()-ul;         
            }
          //--- calculate minimum and maximum time for both measurements
          if(ui_min>ui_res) ui_min=ui_res;
          if(ui_maxul_res) ul_min=ul_res;
          if(ul_max

    See Also

  • [GetTickCount](/common/gettickcount)
  • [Date and Time](/dateandtime)