matlab-write-performance-tests

Write MATLAB performance tests using matlab.perftest.TestCase and runperf.

883|109|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-write-performance-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-write-performance-tests
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/matlab-software-development/matlab-write-performance-tests
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-write-performance-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing trustworthy MATLAB performance tests is hard because naive timing (or poorly structured tests) produces noisy, non-reproducible results that mask real regressions.

Core Features & Use Cases

  • Statistically rigorous benchmarking using matlab.perftest.TestCase with warmup, multiple samples, and outlier handling.
  • Proper measurement boundaries via keepMeasuring for fast code, or startMeasuring/stopMeasuring to isolate exactly what you want timed.
  • Correct parameterization patterns using MethodSetupParameter for values consumed during setup, plus guidance to avoid common MATLAB perf-test gotchas.
  • Best-practice test design including RNG seeding, avoiding setup inside the measured region, and using local variables to reduce measurement overhead.

What problem does it solve?

Aizes performance-test development for MATLAB code by generating clean, repeatable benchmark classes that work well with runperf and matlab.perftest.TestCase.

Quick Start

Use this skill to write a matlab.perftest.TestCase performance test for your function, benchmark it across multiple input sizes, and run it with runperf to get median timing and regression-ready results.

Frequently Asked Questions about matlab-write-performance-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write MATLAB performance tests to benchmark my code accurately?

To write MATLAB performance tests, use matlab.perftest.TestCase with runperf to benchmark code accurately. Apply keepMeasuring for fast code or startMeasuring and stopMeasuring to isolate timed regions, ensuring statistical rigor through warmup and multiple samples.

Why does my MATLAB performance test produce noisy or non-reproducible timing results?

MATLAB performance tests produce noisy timing results when setup code runs inside the measured region or RNG seeding is non-deterministic. Enforce setup and verification separation, use local variables to reduce overhead, and apply deterministic RNG seeding to achieve reproducible benchmarking.

What is the best way to benchmark fast MATLAB functions without measurement overhead?

The best way to benchmark fast MATLAB functions is using the keepMeasuring loop within matlab.perftest.TestCase. This approach minimizes measurement overhead by repeatedly executing the target code until sufficient samples are collected for statistically rigorous timing.

Can I use MethodSetupParameter to test multiple input sizes in a MATLAB performance test?

Yes, you can use MethodSetupParameter to parameterize MATLAB performance tests. It supplies distinct values consumed during the setup phase, allowing you to benchmark code across multiple input sizes cleanly while maintaining proper setup and verification separation.

When should I use startMeasuring and stopMeasuring instead of keepMeasuring in MATLAB benchmarks?

Use startMeasuring and stopMeasuring instead of keepMeasuring when you need to isolate exactly what you want timed in slow MATLAB functions. This approach ensures precise measurement boundaries by excluding setup and verification phases from the benchmark results.