toc - Read elapsed time from
stopwatch - MATLAB (original) (raw)
Usage notes and limitations:
- The data type returned from
toc
is different between MATLAB and the generated code. To avoid errors, do not use a MEX-functiontoc
output value in MATLAB, or a MATLABtoc
output value in a MEX function. - If you call
tic
in a MATLAB session andtoc
in a MEX function, or vice versa, the timing results are not coordinated. - The C/C++ implementation for
toc
in the generated code differs depending on the hardware settings stored in the code generation configuration object. By default, the hardware settings are configured for the host platform, withHardware Board
in the MATLAB Coder™ app set toMATLAB Host Computer
.- When generating code on Windows® with Windows-compatible hardware settings, the generated C/C++ implementation uses the Windows API functions
QueryPerformanceFrequency
andQueryPerformanceCounter
. - In all other cases, the implementation uses the POSIX API
clock_gettime
. When compiling code that uses the POSIX API, the preprocessor macro_POSIX_C_SOURCE
must be set to an integer greater than or equal to199309L
. The code generator sets the macro to199309L
for compilation.
- When generating code on Windows® with Windows-compatible hardware settings, the generated C/C++ implementation uses the Windows API functions
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.