Miscellaneous Topics
Steve Dalton · 2012
This chapter discusses timing function execution in VBA and C/C++ and relative performance of C API versus VBA calling from a worksheet cell. The relative performance of VBA, C/C++ tests and results rely on the ability to time the execution of both VBA and C/C++ DLL worksheet functions. Excel reports the system time to a granularity of 1/100 of a second. VB's Now function only provides access to the system time rounded down to the nearest second. The C run-time library function time() only provides access to the system time to the nearest second as well. A get_time_C() worksheet function that takes a trigger argument and returns the time to the nearest 1/100 of a second in an Excel-compatible number format. A wrapper function, which calls the test function in two nested for loops and that takes a trigger argument, an outer-loop limit, an inner-loop limit and whatever other arguments are needed by the test code.