matlab/matlab-agentic-toolkit / skills-catalog/matlab-software-development/matlab-write-performance-tests
matlab-write-performance-tests
VerifiedWrites MATLAB performance tests using the matlab.perftest.TestCase framework. Use when asked to write, create, or add performance tests for MATLAB code, benchmark functions, measure execution time with statistical rigor, or use runperf.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.4 KB |
| manifest.yaml | config | 478 B |
| references/FeaturePerformanceTest.m | other | 2.3 KB |
| references/simulink-template.md | markdown | 1.5 KB |
| references/tExampleWorkflow.m | other | 1.6 KB |
references/FeaturePerformanceTest.m
View on GitHubclassdef FeaturePerformanceTest < matlab.perftest.TestCase
%FeaturePerformanceTest Performance tests for <Feature>
% Tests <function/API> at various data sizes using the
% matlab.perftest.TestCase framework.
%
% Run with: results = runperf('FeaturePerformanceTest');
properties (MethodSetupParameter)
% Use struct for complex parameter sets
DataSize = struct('Small', struct('n', 100, 'desc', 'baseline'), ...
'Medium', struct('n', 1000, 'desc', 'typical'), ...
'Large', struct('n', 10000, 'desc', 'stress'))
end
properties
inputData
expectedSize
rngState
end
methods (TestMethodSetup)
function setupData(testCase, DataSize)
% ALL setup must be here, outside measurement boundary
testCase.rngState = rng(42, 'twister');
n = DataSize.n;
testCase.inputData = randn(n, 1);
testCase.expectedSize = [n 1];
end
end
methods (TestMethodTeardown)
function restoreRng(testCase)
rng(testCase.rngState);
end
end
methods (Test)
function testFastFunction(testCase, DataSize) %#ok<INUSD>
% Use keepMeasuring for fast operations (<10ms)
data = testCase.inputData;
while testCase.keepMeasuring
result = targetFunction(data);
end
testCase.verifyEqual(size(result), testCase.expectedSize);
end
function testSlowFunction(testCase, DataSize) %#ok<INUSD>
% For slower operations (>10ms), no keepMeasuring needed
% The entire Test method body is measured
data = testCase.inputData;
result = slowTargetFunction(data);
testCase.verifyNotEmpty(result);
end
function testWithBoundaries(testCase, DataSize) %#ok<INUSD>
% Use startMeasuring/stopMeasuring for mid-test setup
data = testCase.inputData;
% Pre-computation (not measured)
preparedData = preprocess(data);
testCase.startMeasuring();
result = targetFunction(preparedData);
testCase.stopMeasuring();
% Verification (not measured)
testCase.verifyTrue(isvalid(result));
end
end
end
% Copyright 2026 The MathWorks, Inc.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |