Main Content

coder.performance.TimingResult

Capture detailed information about execution time of generated code

Since R2024b

    Description

    Use a coder.performance.TimingResult object to get detailed information about the execution times of the generated code.

    To create a coder.performance.TimingResult object, use the coder.timeit function.

    Properties

    expand all

    Name of the generated function, specified as a character vector.

    List of all the individual execution times after the warmup phase, specified as double array.

    The warmup phase is a period to stabilize a system before measuring the execution time.

    First execution times obtained before warmup phase, specified as double.

    Minimum execution time from Runtimes obtained during timing, specified as double.

    Examples

    collapse all

    Find information about the execution time of generated code by creating a coder.performance.TimingResult object and displaying its properties.

    Define the MATLAB® function integralExpLn.

    function out = integralExpLn(xmin,xmax)
        f = @(x) exp(-x.^2).*log(x).^2;
        out = integral(f,xmin,xmax);
    end

    Use the coder.timeit function to create a coder.performance.TimingResult object.

    [~,trObj] = coder.timeit("integralExpLn",1,{0 Inf});
    coder_timeit INFO: Generating code and building MEX.
    coder_timeit INFO: Running MEX.
    TimingResult with 40372 Runtime Sample(s)
    
    Statistical Overview:
       mean = 1.24e-05 s    max = 5.63e-04 s     sd = 4.44e-06 s
     median = 1.20e-05 s    min = 1.15e-05 s   90th = 1.31e-05 s
    

    Use the properties of the coder.performance.TimingResult object to find information about the execution time of the generated code.

    trObj.Name
    ans = 
    'integralExpLn_mex'
    
    trObj.Runtimes(1:5)
    ans = 1×5
    10-4 ×
    
        0.1720    0.1410    0.1400    0.1500    0.1340
    
    
    tIQR = iqr(trObj.Runtimes)
    tIQR = 
    9.0000e-07
    
    trObj.FirstRuntime
    ans = 
    7.4400e-05
    
    trObj.MinRuntime
    ans = 
    1.1500e-05
    

    Version History

    Introduced in R2024b