Main Content

sampleSummary

类: matlab.unittest.measurement.MeasurementResult
命名空间: matlab.unittest.measurement

基于 MeasurementResult 数组创建摘要统计量表

语法

T = sampleSummary(R)

说明

T = sampleSummary(R) 基于 MeasurementResult 数组创建摘要统计量表。

输入参数

全部展开

对测试套件运行测量试验得出的结果数组,指定为 MeasurementResult 数组。

输出参数

全部展开

测量样本摘要,以表格形式返回。表格包含以下列:NameSampleSizeMeanStandardDeviationMinMedianMax

示例

全部展开

在您的当前工作文件夹中创建一个基于类的测试,preallocationTest.m,用于对不同的预分配方法进行比较。

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

创建一个测试套件。

suite = testsuite('preallocationTest');

构造一个采集不定测量值样本数的计时试验,并运行这些测试。

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

基于结果数组 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

版本历史记录

在 R2017a 中推出

另请参阅