Main Content

sampleSummary

Class: matlab.unittest.measurement.MeasurementResult
Namespace: matlab.unittest.measurement

Create table of summary statistics from MeasurementResult array

Syntax

T = sampleSummary(R)

Description

T = sampleSummary(R) creates a table of summary statistics from a MeasurementResult array.

Input Arguments

expand all

Results array from running a measurement experiment on a test suite, specified as a MeasurementResult array.

Output Arguments

expand all

Measurement sample summary, returned as a table. The table contains the following columns: Name, SampleSize, Mean, StandardDeviation, Min, Median, and Max.

Examples

expand all

In your current working folder, create a class-based test, preallocationTest.m, that compares different methods of preallocation.

classdef preallocationTest < matlab.perftest.TestCase
    methods(Test)
        function testOnes(testCase)
            x = ones(1,1e7);
        end
        
        function testIndexingWithVariable(testCase)
            id = 1:1e7;
            x(id) = 1;
        end
        
        function testIndexingOnLHS(testCase)
            x(1:1e7) = 1;
        end
        
        function testForLoop(testCase)
            for i=1:1e7
                x(i) = 1;
            end
        end
        
    end
end

Create a test suite.

suite = testsuite('preallocationTest');

Construct a time experiment with a variable number of sample measurements, and run the tests.

import matlab.perftest.TimeExperiment
experiment = TimeExperiment.limitingSamplingError;
R = run(experiment,suite);
Running preallocationTest
..........
..........
..........
..........
..........
.....
Done preallocationTest
__________

Create a table of summary statistics from the result array R.

T = sampleSummary(R)
T =

  4×7 table array

                       Name                       SampleSize      Mean      StandardDeviation      Min        Median       Max   
    __________________________________________    __________    ________    _________________    ________    ________    ________

    preallocationTest/testOnes                     4             0.02649    0.00086703           0.025583    0.026426    0.027526
    preallocationTest/testIndexingWithVariable    16             0.13356      0.014525            0.11803     0.12716     0.15946
    preallocationTest/testIndexingOnLHS           13            0.073571     0.0073962           0.065024    0.073216    0.086889
    preallocationTest/testForLoop                  6             0.74768       0.03897            0.69934     0.75511     0.79957

Version History

Introduced in R2017a

See Also