← ClaudeAtlas

matlab-optimize-performancelisted

Read BEFORE optimizing any MATLAB code for speed. Without this workflow, agents commonly optimize the wrong target, fabricate speedup claims without measurement, or introduce regressions. Guides the 7-step workflow: baseline, profile, identify, optimize, measure, verify, report.
LiHongwei-cn/lihongwei-cn · ★ 9 · AI & Automation · score 79
Install: claude install-skill LiHongwei-cn/lihongwei-cn
# MATLAB Performance Optimization Workflow Systematic 7-step workflow for finding and fixing performance bottlenecks in MATLAB code. ## When to Use - User asks to speed up or optimize MATLAB code - User wants to find why their MATLAB code is slow - User has a function or script that takes too long to run - User asks to benchmark or time MATLAB code - User wants to compare performance before and after a change - User asks about MATLAB performance best practices ## When NOT to Use - Optimizing Simulink model simulation speed (use Simulink Profiler) - The bottleneck is in compiled C/MEX code that can't be changed at the M-code level - The performance issue is purely I/O-bound (file reads, network, database) - User wants to write performance *tests* (use the `writing-matlab-perf-tests` skill) ## The 7-Step Workflow ### Step 1: Establish Baseline Measure current performance so you have a number to improve against. **For a single function:** ```matlab f = @() targetFunction(input1, input2); baseline = timeit(f); fprintf('Baseline: %.4f s\n', baseline); ``` **For GPU code:** ```matlab f = @() gpuFunction(gpuInput); baseline = gputimeit(f); ``` **For a script or multi-step workflow:** ```matlab % Warmup run (first call includes JIT compilation) myWorkflow(inputs); % Timed run tic; myWorkflow(inputs); baseline = toc; fprintf('Baseline: %.4f s\n', baseline); ``` `timeit` is preferred because it handles warmup and runs multiple samples automatically. ### Step 2: Profile an