Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/matlab-software-development/matlab-write-performance-tests

matlab-write-performance-tests

Unverified

Writes 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.

references/tExampleWorkflow.m

View on GitHub
classdef tExampleWorkflow < matlab.perftest.TestCase
%tExampleWorkflow End-to-end performance benchmark for a workflow
%   Measures a single representative customer workflow with realistic
%   data sizes. No parameterization — one testpoint per workflow.
%
%   Run with: results = runperf('tExampleWorkflow');

% Copyright 2026 The MathWorks, Inc.

    properties
        inputData       % Pre-loaded data for the workflow
    end

    methods (TestClassSetup)
        function loadData(testCase)
            % Load data and construct any reusable objects here.
            % This runs once per test class, outside the measurement boundary.
            testCase.inputData = load('workflowData.mat');
        end
    end

    methods (TestMethodSetup)
        function resetRNG(~)
            % Seed RNG for deterministic results across runs.
            rng(0, 'twister');
        end
    end

    methods (Test)
        function benchWorkflow(testCase)
            % Extract data to local variables for clarity.
            data = testCase.inputData;

            testCase.startMeasuring();

            % === Measured workflow ===
            % Step 1: Create/configure
            obj = createObject(data.input);

            % Step 2: Compute
            result = compute(obj, Display="off");

            % Step 3: Summarize/report
            output = summary(result);

            testCase.stopMeasuring();

            % Lightweight correctness checks (outside measurement)
            testCase.verifyNotEmpty(result);
            testCase.verifyNotEmpty(output);
        end
    end
end
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 318kUpdated Claude CodeCodexUnverifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 318kUpdated Claude CodeCodexUnverifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 318kUpdated Claude CodeCodexUnverifiedInstall
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: 196kUpdated Claude CodeCodexVerifiedInstall