algorithmic-art
Generate deterministic SVG algorithmic artwork. Invoke when the user asks for geometric,…
Optimize code performance through iterative improvements (max 2 rounds). Benchmark execution time and memory usage, compare against baseline implementations, and generate detailed optimization reports. Supports C++, Python, Java, Rust, and other languages.
$ npx -y skills add bytedance/agentkit-samples --skill code-optimization --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/code-optimizationContext preview
The summary Claude sees to decide when to auto-load this skill.
Optimize code performance through iterative improvements (max 2 rounds). Benchmark execution time and memory usage, compare against baseline implementations, and generate detailed optimization reports. Supports C++, Python, Java, Rust, and other languages.
name: code-optimization description: Optimize code performance through iterative improvements (max 2 rounds). Benchmark execution time and memory usage, compare against baseline implementations, and generate detailed optimization reports. Supports C++, Python, Java, Rust, and other languages. license: Complete terms in LICENSE.txt
You are an expert code optimization assistant focused on improving code performance beyond standard library implementations.
Use this skill when users need to:
**IMPORTANT**:
Use file-related tools to:
**Example**:
# Read code file
content = read_file("topk_benchmark.cpp")
# Analyze and implement optimization
# Fill in the my_topk_inplace function with optimized implementationExecute code via command line to measure performance:
**For C++ code**:
# Compile with optimization flags g++ -O3 -std=c++17 topk_benchmark.cpp -o topk_benchmark # Run and capture output ./topk_benchmark
**For Python code**:
python3 optimization_benchmark.py
**For other languages**:
# Java javac MyOptimization.java && java MyOptimization # Rust rustc -O optimization.rs && ./optimization # Go go build optimization.go && ./optimization
From execution output, extract:
**Example output to parse**:
N=160000, K=16000 std::nth_element time: 1234 us (1.234 ms) my_topk_inplace time: 567 us (0.567 ms) Verification: PASS Speedup: 2.18x faster
**Repeat Steps 1-3 up to 2 times maximum** to achieve optimal performance:
**Stopping criteria**:
Save optimized code and generate report:
**Save optimized code**:
# Save to code_optimization directory
write_file("code_optimization/topk_benchmark_optimized.cpp", optimized_code)**Generate optimization report** (`code_optimization/report.md`):
# Code Optimization Report ## 【优化版本】v1 ### 【优化内容】 1. 使用 std::partial_sort 替代 std::nth_element,减少额外排序开销 2. 优化内存分配策略,使用 reserve() 预分配空间 3. 原因:partial_sort 对前 K 个元素的局部排序更高效 ### 【优化后性能】 - 运行时间:从 1234 us 优化到 567 us - 性能提升:54% 更快 - 内存占用:640 KB(与基线相同) ### 【和标准库对比】 - 比 std::nth_element 快 667 us(约 2.18x 倍速) - 验证结果:PASS(输出与标准库完全一致) --- ## 【优化版本】v2 ### 【优化内容】 1. 引入快速选择算法(Quick Select)优化分区过程 2. 使用 SIMD 指令加速比较操作(AVX2) 3. 原因:减少分支预测失败,提高 CPU 流水线效率 ### 【优化后性能】 - 运行时间:从 567 us 优化到 312 us - 性能提升:相比 v1 快 45% - 内存占用:640 KB(无额外开销) ### 【和标准库对比】 - 比 std::nth_element 快 922 us(约 3.95x 倍速) - 验证结果:PASS --- ## 最终总结 ### 最佳版本:v2 (达到最大迭代次数) - **总体性能提升**:从基线 1234 us 优化到 312 us(74.7% 性能提升) - **相比标准库**:快 3.95 倍 - **优化策略**:算法改进 + SIMD 向量化 - **迭代次数**:2 轮(已达上限) - **适用场景**:大规模数据(N > 100K)的 Top-K 查询 - **权衡考虑**:无额外内存开销,代码复杂度适中 ### 优化技术总结 1. 算法层面:Quick Select(线性期望时间) 2. 指令级别:SIMD 向量化(AVX2) 3. 编译优化:-O3 -march=native
**Option A: Low-Level Optimizations** (for CPU-bound tasks)
**Option B: Concurrency** (for parallelizable tasks)
欢迎来到 AgentKit 代码工坊(Samples)仓库! AgentKit 是火山引擎推出的企业级 AI Agent 开发平台,为开发者提供完整的 Agent 构建、部署和运维解决方案。平台通过标准化的开发工具链和云原生基础设施,显著降低复杂智能体应用的开发部署门槛。 本代码库包含了一系列示例和教程,帮助您理解、实现和集成 AgentKit 的各项功能到您的应用中。
Generate deterministic SVG algorithmic artwork. Invoke when the user asks for geometric,…
根据文字描述生成视频,一个生成图片和视频的工作流技能。依赖 skills: byted-web-search, image-generate, video-generate。注意:此…
Manage AgentKit skills, SkillHub/skillhub, skill centers, and skill spaces. Use this skill…
Upload files or directories to TOS-compatible object storage for Volcano Engine or BytePlus…
根据用户的功能需求,完成与 VeADK-Go 相关的功能; 包括:直接根据需求生成 Agent;将Enio Agent转换为VeADK-Go Agent。