MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Construct an explicit test suite. Since you are measuring the first-time cost of the
function, run a single test. To run multiple tests, save the results and start a new MATLAB
session between tests.


suite = testsuite('fprintfTest/testPrintingToFile');


Construct and run the time experiment.


import matlab.perftest.TimeExperiment
experiment = TimeExperiment.withFixedSampleSize(1);
results = run(experiment,suite);


Running fprintfTest
.
Done fprintfTest




Display the results. Observe the TestActivity table to ensure there are no warm-up
samples.


fullTable = results.TestActivity


fullTable =
1×12 table
Name Passed Failed Incomplete MeasuredTime Objective Timestamp Host Platform Version TestResult RunIdentifier




fprintfTest/testPrintingToFile true false false 0.09189 sample 26-Oct-2018 14:18:46 MY-HOSTNAME win64 9.6.0.979037 (R2019a) Prerelease [1x1 matlab.unittest.TestResult] 36d0b490-d2cc-4c8c-bac7-395b5976d638


The performance testing framework collects one sample for each test.


See Also


matlab.perftest.TestCase | matlab.perftest.TimeExperiment |
matlab.perftest.TimeResult |
matlab.unittest.measurement.DefaultMeasurementResult | runperf |
testsuite


See Also
Free download pdf