fullTableTE = vertcat(resultsTE.Samples);
summaryStatsTE = varfun(@mean,fullTableTE,...
'InputVariables','MeasuredTime','GroupingVariables','Name')summaryStatsTE =
2×3 table
Name GroupCount mean_MeasuredTime
______________________________ __________ _________________
fprintfTest/testPrintingToFile 7 0.08887
fprintfTest/testBytesToFile 6 0.08836Increase the maximum number of samples to 100 and rerun the time experiment.
experiment = TimeExperiment.limitingSamplingError('NumWarmups',2,...
'RelativeMarginOfError',0.03,'ConfidenceLevel',0.97,'MaxSamples',100);
resultsTE = run(experiment,suite);Running fprintfTest
.......... ....
Done fprintfTest
__________Compute the statistics for all the test elements.fullTableTE = vertcat(resultsTE.Samples);
summaryStatsTE = varfun(@mean,fullTableTE,...
'InputVariables','MeasuredTime','GroupingVariables','Name')summaryStatsTE =
2×3 table
Name GroupCount mean_MeasuredTime
______________________________ __________ _________________
fprintfTest/testPrintingToFile 6 0.088188
fprintfTest/testBytesToFile 4 0.092162The testing framework achieves the statistical objectives for both tests in approximately
50 samples.Measure First-time CostStart a new MATLAB session. A new session ensures that MATLAB has not run the code
contained in your tests.Measure the first-time cost of your code by creating and running a fixed time experiment
with zero warm-up measurements and one sample measurement.33 Unit Testing