Token导航 LogoToken导航

Agent Skill · 研究检索

matlab-performance-optimizer(matlab 性能优化器)

matlab-performance-optimizer 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

matlab-performance-optimizer 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 35,158。

总安装 2,130周安装 87GitHub Stars 74下载 689核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:matlab-performance-optimizer(matlab 性能优化器)
来源仓库:https://github.com/matlab/skills
仓库路径:skills/matlab-performance-optimizer
安装命令:
npx skills add https://github.com/matlab/skills --skill matlab-performance-optimizer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/matlab/skills --skill matlab-performance-optimizer

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

matlab-performance-optimizer 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词快速定位候选结果时使用。适用于性能优化和系统调优等研究检索场景。

通过 npx skills add 命令从 GitHub 仓库安装,需确认权限范围和文件读写操作。建议结合原始 README 核验具体用法,注意维护状态和网络访问限制。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/matlab-performance-optimizer

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/matlab/skills --skill matlab-performance-optim…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

matlab-performance-optimizer 怎么安装?

在终端执行 npx skills add https://github.com/matlab/skills --skill matlab-performance-optimizer。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

matlab-performance-optimizer 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

matlab-performance-optimizer 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

matlab-performance-optimizer 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

matlab-performance-optimizer 用的人多吗?

公开数据是累计安装 2,130 次,近一周安装 87 次,下载 689 次,GitHub 74 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

matlab-performance-optimizer 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
matlab-performance-optimizer

matlab 性能优化器 · 本页

2,13074需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

MATLAB Performance Optimizer

This skill provides comprehensive guidelines for optimizing MATLAB code performance. Apply vectorization techniques, memory optimization strategies, and profiling tools to make code faster and more efficient.

When to Use This Skill

  • Optimizing slow or inefficient MATLAB code
  • Converting loops to vectorized operations
  • Reducing memory usage
  • Improving algorithm performance
  • When user mentions: slow, performance, optimize, speed up, efficient, memory
  • Profiling code to find bottlenecks
  • Parallelizing computations

Core Optimization Principles

1. Vectorization (Most Important)

Replace loops with vectorized operations whenever possible.

SLOW - Using loops:

% Slow approach
n = 1000000;
result = zeros(n, 1);
for i = 1:n
    result(i) = sin(i) * cos(i);
end

FAST - Vectorized:

% Fast approach
n = 1000000;
i = (1:n).';
result = sin(i) .* cos(i);

2. Preallocate Arrays

Always preallocate arrays before loops.

SLOW - Growing arrays:

% Very slow - array grows each iteration
result = [];
for i = 1:10000
    result(end+1) = i^2;
end

FAST - Preallocated:

% Fast - preallocated array
n = 10000;
result = zeros(n, 1);
for i = 1:n
    result(i) = i^2;
end

3. Use Built-in Functions

MATLAB built-in functions are highly optimized.

SLOW - Manual implementation:

% Slow
sum_val = 0;
for i = 1:length(x)
    sum_val = sum_val + x(i);
end

FAST - Built-in function:

% Fast
sum_val = sum(x);

Vectorization Techniques

Element-wise Operations

Use .*, ./, .^ for element-wise operations:

% Instead of this:
for i = 1:length(x)
    y(i) = x(i)^2 + 2*x(i) + 1;
end

% Do this:
y = x.^2 + 2*x + 1;

Logical Indexing

Replace conditional loops with logical indexing:

% Instead of this:
count = 0;
for i = 1:length(data)
    if data(i) > threshold
        count = count + 1;
        filtered(count) = data(i);
    end
end
filtered = filtered(1:count);

% Do this:
filtered = data(data > threshold);

Matrix Operations

Use matrix multiplication instead of nested loops:

% Instead of this:
C = zeros(size(A, 1), size(B, 2));
for i = 1:size(A, 1)
    for j = 1:size(B, 2)
        for k = 1:size(A, 2)
            C(i,j) = C(i,j) + A(i,k) * B(k,j);
        end
    end
end

% Do this:
C = A * B;

Cumulative Operations

Use cumsum, cumprod, cummax, cummin:

% Instead of this:
running_sum = zeros(size(data));
running_sum(1) = data(1);
for i = 2:length(data)
    running_sum(i) = running_sum(i-1) + data(i);
end

% Do this:
running_sum = cumsum(data);

Memory Optimization

Use Appropriate Data Types

% Instead of default double (8 bytes)
data = rand(1000, 1000);  % 8 MB

% Use single precision when appropriate (4 bytes)
data = single(rand(1000, 1000));  % 4 MB

% Use integers when applicable
indices = uint32(1:1000000);  % 4 MB instead of 8 MB

Sparse Matrices

For matrices with mostly zeros:

% Dense matrix (wastes memory)
A = zeros(10000, 10000);
A(1:100, 1:100) = rand(100);  % 800 MB

% Sparse matrix (efficient)
A = sparse(10000, 10000);
A(1:100, 1:100) = rand(100);  % Only stores non-zeros

Clear Unused Variables

% Process large data
largeData = loadData();
processedData = processData(largeData);

% Clear when no longer needed
clear largeData;

% Continue with processed data
results = analyze(processedData);

In-Place Operations

% Instead of creating copies
A = A + 5;  % In-place when possible

% Avoid unnecessary copies
B = A;      % Creates copy if A is modified later
B = A + 0;  % Forces copy

Profiling and Benchmarking

Using the Profiler

% Profile code execution
profile on
myFunction(inputs);
profile viewer
profile off

The profiler shows:

  • Time spent in each function
  • Number of calls to each function
  • Lines that take the most time

Timing Comparisons

% Time single execution
tic;
result = myFunction(data);
elapsedTime = toc;

% Benchmark with timeit (more accurate)
timeit(@() myFunction(data))

% Compare multiple approaches
time1 = timeit(@() approach1(data));
time2 = timeit(@() approach2(data));
fprintf('Approach 1: %.6f s\nApproach 2: %.6f s\n', time1, time2);

Common Optimization Patterns

Pattern 1: Replace find with Logical Indexing

% SLOW
indices = find(x > 5);
y = x(indices);

% FAST
y = x(x > 5);

Pattern 2: Use Implicit Expansion Instead of repmat

% SLOW - repmat to match dimensions
A = rand(1000, 5);
B = rand(1, 5);
C = A - repmat(B, size(A, 1), 1);

% FAST - implicit expansion (R2016b+)
C = A - B;

Pattern 3: Avoid Repeated Calculations

% SLOW - recalculates each iteration
for i = 1:n
    result(i) = data(i) / sqrt(sum(data.^2));
end

% FAST - calculate once
norm_factor = sqrt(sum(data.^2));
for i = 1:n
    result(i) = data(i) / norm_factor;
end

% EVEN FASTER - vectorize
result = data / sqrt(sum(data.^2));

Pattern 4: Efficient String Operations

% SLOW - concatenating in loop
str = '';
for i = 1:1000
    str = [str, sprintf('Line %d\n', i)];
end

% FAST - cell array + join
lines = cell(1000, 1);
for i = 1:1000
    lines{i} = sprintf('Line %d', i);
end
str = strjoin(lines, '\n');

% FASTEST - vectorized sprintf
str = sprintf('Line %d\n', 1:1000);

Pattern 5: Use Table for Mixed Data Types

% Instead of separate arrays
names = cell(1000, 1);
ages = zeros(1000, 1);
scores = zeros(1000, 1);

% Use table
data = table(names, ages, scores);
% Faster access and better organization

Algorithm-Specific Optimizations

Convolution and Filtering

% Use built-in functions
filtered = conv(signal, kernel, 'same');
filtered = filter(b, a, signal);

% For 2D
filtered = conv2(image, kernel, 'same');
filtered = imfilter(image, kernel);

% FFT-based for large kernels (zero-pad for linear convolution)
nfft = length(signal) + length(kernel) - 1;
filtered = ifft(fft(signal, nfft) .* fft(kernel, nfft));

Distance Calculations

% Instead of nested loops for pairwise distances
% SLOW
n = size(points, 1);
distances = zeros(n, n);
for i = 1:n
    for j = 1:n
        distances(i,j) = norm(points(i,:) - points(j,:));
    end
end

% FAST - vectorized
distances = pdist2(points, points);

Sorting and Searching

% Presort for multiple searches
sortedData = sort(data);

% Binary search on sorted data
idx = find(sortedData >= value, 1, 'first');

% Use ismember for set operations
[isPresent, locations] = ismember(searchValues, data);

% Use unique for removing duplicates
uniqueData = unique(data);

Parallel Computing

Simple Parallel Loops (parfor)

% Convert for to parfor for independent iterations
parfor i = 1:n
    results(i) = expensiveFunction(data(i));
end

Requirements for parfor:

  • Iterations must be independent
  • Loop variable must be consecutive integers
  • Variables must be classified as loop, sliced, broadcast, or reduction

Parallel Array Operations

% Create parallel pool
parpool('local', 4);  % 4 workers

% Use parfeval for asynchronous parallel execution
futures = parfeval(@expensiveFunction, 1, data);
result = fetchOutputs(futures);

% GPU arrays for massive parallelization
gpuData = gpuArray(data);
result = arrayfun(@myFunction, gpuData);
result = gather(result);  % Bring back to CPU

Advanced Optimizations

MEX Functions for Critical Sections

Convert performance-critical code to C/C++:

% Create MEX file for bottleneck function
% Write myFunction.c, then compile:
% mex myFunction.c

% Call like regular MATLAB function
result = myFunction(inputs);

Persistent Variables for Cached Results

function result = expensiveComputation(input)
    persistent cachedData cachedInput

    if isequal(input, cachedInput)
        % Return cached result
        result = cachedData;
        return;
    end

    % Compute and cache
    result = computeExpensiveOperation(input);
    cachedData = result;
    cachedInput = input;
end

JIT Acceleration Best Practices

MATLAB's JIT (Just-In-Time) compiler optimizes:

  • Simple for-loops with scalar operations
  • Functions without dynamic features

JIT-friendly code:

function result = jitFriendly(n)
    result = 0;
    for i = 1:n
        result = result + i;
    end
end

JIT-unfriendly code (avoid):

function result = jitUnfriendly(n)
    result = 0;
    for i = 1:n
        eval(['x' num2str(i) ' = i;']);  % Dynamic code
    end
end

Performance Checklist

Before finalizing optimized code, verify:

  • Loops are vectorized where possible
  • Arrays are preallocated before loops
  • Built-in functions used instead of manual implementations
  • Logical indexing used instead of find + indexing
  • Appropriate data types used (single vs double, integers)
  • Sparse matrices used for sparse data
  • Repeated calculations moved outside loops
  • String concatenation uses efficient methods
  • Code profiled to identify actual bottlenecks
  • Matrix operations used instead of element-wise loops
  • Parallel computing considered for independent operations
  • Memory-intensive operations optimized
  • Caching implemented for repeated expensive calls

Profiling Workflow

  1. Measure First: Profile before optimizing profile on myScript; profile viewer
  2. Identify Bottlenecks: Focus on functions taking most time
  3. Optimize: Apply appropriate techniques
  4. Measure Again: Verify improvement % Before time_before = timeit(@() myFunction(data)); % After optimization time_after = timeit(@() myFunctionOptimized(data)); fprintf('Speedup: %.2fx\n', time_before/time_after);
  5. Iterate: Repeat for remaining bottlenecks

Common Performance Pitfalls

Pitfall 1: Premature Optimization

  • Profile first, optimize second
  • Focus on actual bottlenecks, not assumptions

Pitfall 2: Over-vectorization

  • Sometimes loops are clearer and fast enough
  • Balance readability with performance

Pitfall 3: Ignoring Memory Access Patterns

% SLOW - inner loop over columns (row-major traversal in column-major MATLAB)
for i = 1:rows
    for j = 1:cols
        A(i,j) = process(i, j);
    end
end

% FAST - inner loop over rows (column-major traversal, contiguous memory)
for j = 1:cols
    for i = 1:rows
        A(i,j) = process(i, j);
    end
end

% FASTEST - vectorized
[I, J] = ndgrid(1:rows, 1:cols);
A = process(I, J);

Pitfall 4: Unnecessary Data Type Conversions

% SLOW - repeated conversions
for i = 1:n
    x = double(data(i));
    result(i) = sin(x);
end

% FAST - convert once
x = double(data);
result = sin(x);

Optimization Examples

Example 1: Image Processing

% SLOW
[rows, cols] = size(image);
output = zeros(rows, cols);
for i = 2:rows-1
    for j = 2:cols-1
        output(i,j) = mean(image(i-1:i+1, j-1:j+1), 'all');
    end
end

% FAST
kernel = ones(3,3) / 9;
output = conv2(image, kernel, 'same');

Example 2: Statistical Analysis

% SLOW
n = size(data, 1);
means = zeros(n, 1);
for i = 1:n
    means(i) = mean(data(i, :));
end

% FAST
means = mean(data, 2);

Example 3: Time Series Processing

% SLOW
n = length(signal);
movingAvg = zeros(size(signal));
window = 10;
for i = window:n
    movingAvg(i) = mean(signal(i-window+1:i));
end

% FAST - trailing window: [window-1 past samples, 0 future samples]
movingAvg = movmean(signal, [window-1 0]);

Troubleshooting Performance

Issue: Code still slow after vectorization

  • Solution: Profile to find new bottlenecks; consider algorithm complexity

Issue: Out of memory errors

  • Solution: Use smaller data types, process in chunks, use sparse matrices

Issue: parfor slower than for loop

  • Solution: Check if overhead outweighs benefits; ensure iterations are expensive enough

Issue: GPU computation slower than CPU

  • Solution: Data transfer overhead may exceed computation time; use for large arrays

Additional Resources

  • Use profile viewer to analyze performance
  • Use memory to check memory usage
  • Use doc with: timeit, tic/toc, parfor, gpuArray, sparse
  • Check MATLAB Performance and Memory documentation

平台分布

Codex

33.86%
按下载量换算233

Claude

32.24%
按下载量换算222

Cursor

18.14%
按下载量换算125

Gemini CLI

9.68%
按下载量换算67

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills