스크립트: sTimeToVariables

 

sTimeToVariables:

초 단위의 시간을 연, 월, 일, 시, 분, 초로 변환하는 기능이 있는 스크립트입니다. mql 함수를 사용하지 않고!

Author: Dmitry Fedoseev

 
더 빠른가요?
 

시간 낭비!

 
onewithzachy:

시간 낭비!

아니, 더 빠르면...
 

타임투스트럭트보다 4배 더 빠른 sTimeToVariable

결과:
2012.08.04 12:23:09 sTimeToVariables (GOLD,M1) sTimeToVariables performance: 24.190035%
2012.08.04 12:23:09 sTimeToVariables (GOLD,M1) sTimeToVariables: 42891604
2012.08.04 12:22:55 sTimeToVariables (GOLD,M1) TimeToStruct: 10375494

#import "kernel32.dll"
bool QueryPerformanceCounter(int &counter[]);
#import
//+------------------------------------------------------------------+
//| 스크립트 시작 함수|
//+------------------------------------------------------------------+
int OnStart()
  {
   int counter[2];
   int start;

   datetime TimeNow=TimeCurrent();
   MqlDateTime tm;

   long today=TimeCurrent();

   QueryPerformanceCounter(counter);
   start=counter[0];
   for(int i=0;i<100000000;i++)
      TimeToStruct(TimeNow,tm);
   QueryPerformanceCounter(counter);
   long T1=counter[0]-start;
   Print("TimeToStruct: ",T1);

   QueryPerformanceCounter(counter);
   start=counter[0];
   for(int i=0;i<100000000;i++)
      fTimeToVariables(TimeNow,tm);
   QueryPerformanceCounter(counter);
   long T2=counter[0]-start;
   Print("fTimeToVariables: ",T2);

   PrintFormat("fTimeToVariables performace: %f%%",double(T1)/double(T2)*100);

   return(0);
  }
//+------------------------------------------------------------------+
//| fTimeToVariables|
//+------------------------------------------------------------------+
void fTimeToVariables(datetime TIME,MqlDateTime&  dt_struct )
  {
   int dst=(int)TIME%86400;
   dt_struct.hour=dst/3600;
   dst-=(dt_struct.hour*3600);
   dt_struct.min=dst/60;
   dt_struct.sec=dst%60;
   int dn=(int)TIME/86400;
   int edn=dn+365;
   int qen=edn/1461;
   int dfqs=edn-(qen*1461);
   int yfqs;
   int dfys;
   if(dfqs<1095)
     {
      yfqs=dfqs/365;
      dt_struct.year=1969+qen*4+yfqs;
      dfys=dfqs-(yfqs*365);
     }
   else
     {
      yfqs=3;
      dt_struct.year=1969+qen*4+yfqs;
      dfys=dfqs-(yfqs*365);
      if(dfys==59)
        {
         dt_struct.mon=2;
         dt_struct.day=29;
         return;
        }
      else if(dfys>59)
        {
         dfys--;
        }
     }
   int mei[]={-1,30,58,89,119,150,180,211,242,272,303,333,364};
   for(dt_struct.mon=1;dt_struct.mon<13;dt_struct.mon++)
     {
      if(dfys<=mei[dt_struct.mon])
        {
         dt_struct.day=dfys-mei[dt_struct.mon-1];
         return;
        }
     }
  }
 
VincentX:

타임투스트럭트보다 4배 빠른 sTimeToVariable

시간 낭비!

적어도 시간 컴포넌트를 추출하는 방법은 보여줍니다.


안녕하세요 VincentX,

kernel32의 쿼리 퍼포먼스 카운터를 사용한 멋진 코드, 감사합니다.

 

onewithzachy: Would you repost the code using SRC butt-on

도와주셔서 감사합니다!

 
onewithzachy:

안녕하세요 VincentX,

무슨 도움 ???

;)

SRC 버튼...

소스를 먼저 올렸습니다.

 

이상해, 뭐야?

MqlDateTime tm;
 
lazarev-d-m:

이상해, 뭐야?

MqlDateTime
 
"mql 함수를 사용하지 않고!"에 대한 비꼬기였습니다.