119 lines
2.2 KiB
Plaintext
119 lines
2.2 KiB
Plaintext
'========
|
|
'TIME API
|
|
'========
|
|
|
|
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
|
|
|
|
extern lib "kernel32.dll"
|
|
|
|
type SYSTEMTIME
|
|
WORD wYear
|
|
WORD wMonth
|
|
WORD wDayOfWeek
|
|
WORD wDay
|
|
WORD wHour
|
|
WORD wMinute
|
|
WORD wSecond
|
|
WORD wMilliseconds
|
|
end type
|
|
|
|
void GetSystemTime(SYSTEMTIME*t)
|
|
void GetLocalTime(SYSTEMTIME*t)
|
|
void QueryPerformanceCounter(quad*c)
|
|
void QueryPerformanceFrequency(quad*freq)
|
|
void Sleep(sys millisecods)
|
|
|
|
end extern
|
|
|
|
String WeekDay[7]={"Sunday","Monday","Tuesday","Wednesday",
|
|
"Thursday","Friday","Saturday"}
|
|
|
|
String MonthName[12]={"January","February","March","April","May","June",
|
|
"July","August","September","October","November","December"}
|
|
|
|
|
|
'==============
|
|
Class Jobrecord
|
|
'==============
|
|
|
|
has SYSTEMTIME stt
|
|
has SYSTEMTIME fin
|
|
quad countA
|
|
quad CountB
|
|
quad freq
|
|
sys serial
|
|
|
|
method pad(string s) as string
|
|
method=s
|
|
if len(method)<2 then method="0"+method
|
|
end method
|
|
|
|
|
|
method ShowDateTime(sys a,f) as string
|
|
|
|
SYSTEMTIME *t
|
|
|
|
if a then
|
|
@t=@fin
|
|
else
|
|
@t=@stt
|
|
end if
|
|
'
|
|
String month=pad(str t.wMonth)
|
|
String day=pad(str t.wDay)
|
|
if f=0 then
|
|
return "" t.wYear "-" month "-" day " "+
|
|
pad(t.wHour) ":" pad(t.wMinute) ":" pad(t.wSecond) ":" t.wMilliSeconds
|
|
elseif f=1
|
|
return WeekDay[t.wDayOfWeek+1 and 7 ] " " +
|
|
MonthName[t.wMonth and 31] " " day " " t.wYear
|
|
end if
|
|
end method
|
|
|
|
method Start()
|
|
QueryPerformanceCounter countA
|
|
QueryPerformanceFrequency freq
|
|
serial++
|
|
GetLocalTime stt
|
|
end method
|
|
|
|
method Finish()
|
|
GetLocalTime fin
|
|
QueryPerformanceCounter countB
|
|
end method
|
|
|
|
|
|
method ShowDuration() as string
|
|
return str((countB-countA)/freq,6) 'seconds with microsecond resolution
|
|
end method
|
|
|
|
method report() as string
|
|
string tab=chr(9), cr=chr(13)+chr(10)
|
|
method="Job:" tab serial cr +
|
|
"Duration:" tab ShowDuration() cr +
|
|
"Start: " tab ShowDateTime(0,0) cr +
|
|
"Finish:" tab ShowDateTime(1,0) cr +
|
|
ShowDateTime(1,1) cr
|
|
end method
|
|
|
|
end class
|
|
|
|
'#recordof JobRecord
|
|
|
|
'====
|
|
'TEST
|
|
'====
|
|
|
|
JobRecord JR
|
|
JR.start
|
|
sleep 100 'JOB!
|
|
JR.finish
|
|
print JR.Report
|
|
'putfile "s.txt",JR.Report
|
|
'
|
|
'Job: 1
|
|
'Duration: 0.099026
|
|
'Start: 2012-07-01 00:52:36:874
|
|
'Finish: 2012-07-01 00:52:36:974
|
|
'Sunday July 01 2012
|