MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

fullTable = vertcat(results.Samples);
summaryStats = varfun(@mean,fullTable,...
'InputVariables','MeasuredTime','GroupingVariables','Name')


summaryStats =
2×3 table
Name GroupCount mean_MeasuredTime




fprintfTest/testPrintingToFile 4 0.090004
fprintfTest/testBytesToFile 4 0.08558


Both test methods write the same amount of data to a file. Therefore, some of the
difference between the mean values is attributed to calling the fprintf function with an
output argument.


Change Statistical Objectives and Rerun Tests


Change the statistical objectives defined by the runperf function by constructing and
running a time experiment. Construct a time experiment with measurements that reach a
sample mean with a 3% relative margin of error within a 97% confidence level. Collect
eight warm-up measurements and up to 32 sample measurements.


Construct an explicit test suite.


suite = testsuite('fprintfTest');


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


import matlab.perftest.TimeExperiment
experiment = TimeExperiment.limitingSamplingError('NumWarmups',8,...
'MaxSamples', 32, 'RelativeMarginOfError',0.03, 'ConfidenceLevel', 0.97);
resultsTE = run(experiment,suite);


Running fprintfTest
.......... .......... .........
Done fprintfTest




In this example output, the performance testing framework is not able to meet the stricter
statistical objectives with the specified number of maximum samples. Your results might
vary.


Compute the statistics for all the test elements.


Test Performance Using Classes
Free download pdf