Einzelnen Beitrag anzeigen
  #2 (permalink)  
Alt 29.05.17
Collider Collider ist offline
Neues Mitglied
 
Registriert seit: Mar 2017
Beiträge: 27
Collider befindet sich auf einem aufstrebenden Ast
Collider eine Nachricht über Skype™ schicken
Standard

Hallo Otto,

ich hatte mir mal eine "Timer" Klasse gebaut mit der ich einfach im Programm Timer starten und stoppen konnte auch mehrere gleichzeitig.

Die Zeiten sind viel zu langsam bei dir.

47 msec für einfache Double ? Klingt sehr langsam. Ich meine das ich nie solche langen Zeiten hatte für einfache Sachen wie du schreibst.


Ich hänge mal den CE_Time Klasse unten an

Gruß

PHP-Code:
//+------------------------------------------------------------------+
//|                                                         Time.mqh |
//|                        Collider                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#include <Object.mqh>
#include <Arrays\List.mqh>
#include <CNodeInt.mqh>
#include <CiSingleList.mqh>
#include <CDoubleNode.mqh>


class CE_Time 
{
 private:
           
 
ulong     ticks_start       ;
 
ulong     ticks_stop        ;
 
double    result_ms         ;     
 
string    text_out          ;
 
string    timer_name        ;
 
bool      TEXT_OUT          ;
 
 
CiSingleList sList          ;
 
 public:
 
                     
CE_Time() {}                                                    ;
                    ~
CE_Time() {}                                                    ;
               
 
bool                init()                                                          ;//Initialize 
 
bool                set_Text_Out(const bool b_text_out)                             ;
 
bool                set_Size_List(const int i_size_list)                            ;   
 
bool                start(const string timer_name)                                  ;//Set Name
 
double              stop_Text_Out()                                                 ; 
 
bool                stop_SaveToList(const uint list_elements)                       ;
 
void                Print_List()                                                    ;     
 
double              Print_Avg_List()                                                ;
 
double              stop()                                                          ; 

 
//int                 getData()        {return 12;}                     ;


 
};




bool CE_Time::init(void)
{
 
  



 
  
  return 
true;
};

bool CE_Time::set_Text_Out(bool b_text_out)
{

  
TEXT_OUT b_text_out;
  return 
true ;
};



bool CE_Time::start(string s_name)
{
    
ticks_start=GetMicrosecondCount();
    
timer_name s_name;
    return 
true;
};



double CE_Time::stop_Text_Out()
{
    
ticks_stop=GetMicrosecondCount()-ticks_start;  
    
double d_result_msticks_stop/1000.0;
    
string comment=StringFormat("Total Time of %s : %.3f ms",timer_name,d_result_ms);

    
    if(
TEXT_OUT)
    {
      Print(
comment);
      
Comment(comment);
    }
    return 
d_result_ms;
};

double CE_Time::stop(void)
{
    
ticks_stop=GetMicrosecondCount()-ticks_start;  
    
double d_result_msticks_stop/1000.0;    
    return 
d_result_ms;
};

bool CE_Time::stop_SaveToList(uint ui_elements )
{
    
ticks_stop=GetMicrosecondCount()-ticks_start;  
    
//double d_result_ys= ticks;
    
sList.AddFront((int)ticks_stop);  
    if(
sList.Size() > ui_elements)
       {
         
sList.RemoveRear();
       }
    
    return 
true;    

};

void CE_Time::Print_List(void)
{
  
TRACE_CALL(_t_flag)
  
sList.PrintList(text_out);

};

double CE_Time::Print_Avg_List(void)
{
   
TRACE_CALL(_t_flag)
   
uint ui_size sList.Size();
   if(
ui_size 1) return 0;
   
uint ui_all  0;
   
   for(
uint i=0;i<ui_size;i++)
    {
     
ui_all += sList.GetValByIndex(i);

    }
    
double db_avg ui_all/ui_size ;
    
    
string comment=StringFormat("Avg Time of %s : %.3f ms with %i Elements in List",timer_name,db_avg/1000,ui_size);

    
    if(
TEXT_OUT)
    {
      Print(
comment);
      
Comment(comment);
    }
    return 
db_avg;
      
};