Of interest is the code that performs the actual measurements. Any other code (such as job implementation or dispatching) that is required to demonstrate the rate tracking is helpful, but not the focus.

Multiple approaches are allowed (even preferable), so long as they can accomplish these goals:

 Run N seconds worth of jobs and/or Y jobs.
 Report at least three distinct times.

Be aware of the precision and accuracy limitations of your timing mechanisms, and document them if you can.

See also: System time, Time a function

 
'========
'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
 