The algorithm to time an application is to store the results of System time before starting a long process (start time) and then again store the system timer when the process is done (ending time).
Access VBA
The elapsed time is the difference between the ending time and start time. The high level view is to:Step A: Declare the API call in a separate module. For more detail refer to this article
Step B: Calling the GetTickCount() API function as strategic points in the long running process
Step C: Calculate the elapsed time and update the user
Step C: Calculate the elapsed time and update the user
DoCmd.Hourglass True
lngStartTime = GetTickCount() Call SysCmd(acSysCmdInitMeter, "Downloading files ...", Me.lvHistory.ListItems.Count) For Each objli In Me.lvHistory.ListItems Call CreateDailyWorkWB5(objli.SubItems(DailyWorkDetail.ClientID), _ objli.SubItems(DailyWorkDetail.ClientName), _ COB_Date, _ intVersionNo, _ intPriorVersionNo:=getPriorVersionNo()) iCounter = iCounter + 1 Call SysCmd(acSysCmdUpdateMeter, iCounter) Next lngEndTime = GetTickCount() lngElapsedTime = (lngEndTime - lngStartTime) * 0.001 MsgBox "Just exported " & Format(iCounter, "##,##0") & " record(s) in " & _ Format(lngElapsedTime, "##,##0") & " second(s) ", vbInformation, "Results"
C#
intStartTime = Environment.TickCount; recordsAffected=objTask.RefreshCDLReferenceFile(strFileName,strFileNameAccess:strAccessDb); intEndTime = Environment.TickCount; decElapsedTime = (decimal)((intEndTime - intStartTime) * .001); MessageBox.Show("Imported " + recordsAffected.ToString() + " row(s) in " + decElapsedTime.ToString() + " sec(s)", "Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
See Also
More info about the Tickcount property