Profiling and Optimization

Profiling and Optimization

Guides an AI agent to profile application performance, read flame graphs and benchmarks, and optimise hot paths in Node.js, Python and database queries.

Skill files9 files

references/

scripts/

templates/

SKILL.md96 lines
1
---
2
name: profiling-optimization
3
description: >
4
Profile application performance, identify bottlenecks, and optimize hot paths
5
using CPU profiling, flame graphs, and benchmarking. Use when investigating
6
performance issues or optimizing critical code paths.
7
---
8
9
# Profiling & Optimization
10
11
## Table of Contents
12
13
- [Overview](#overview)
14
- [When to Use](#when-to-use)
15
- [Quick Start](#quick-start)
16
- [Reference Guides](#reference-guides)
17
- [Best Practices](#best-practices)
18
19
## Overview
20
21
Profile code execution to identify performance bottlenecks and optimize critical paths using data-driven approaches.
22
23
## When to Use
24
25
- Performance optimization
26
- Identifying CPU bottlenecks
27
- Optimizing hot paths
28
- Investigating slow requests
29
- Reducing latency
30
- Improving throughput
31
32
## Quick Start
33
34
Minimal working example:
35
36
```typescript
37
import { performance, PerformanceObserver } from "perf_hooks";
38
39
class Profiler {
40
private marks = new Map<string, number>();
41
42
mark(name: string): void {
43
this.marks.set(name, performance.now());
44
}
45
46
measure(name: string, startMark: string): number {
47
const start = this.marks.get(startMark);
48
if (!start) throw new Error(`Mark ${startMark} not found`);
49
50
const duration = performance.now() - start;
51
console.log(`${name}: ${duration.toFixed(2)}ms`);
52
53
return duration;
54
}
55
56
async profile<T>(name: string, fn: () => Promise<T>): Promise<T> {
57
const start = performance.now();
58
59
try {
60
return await fn();
61
} finally {
62
// ... (see reference guides for full implementation)
63
```
64
65
## Reference Guides
66
67
Detailed implementations in the `references/` directory:
68
69
| Guide | Contents |
70
|---|---|
71
| [Node.js Profiling](references/nodejs-profiling.md) | Node.js Profiling |
72
| [Chrome DevTools CPU Profile](references/chrome-devtools-cpu-profile.md) | Chrome DevTools CPU Profile |
73
| [Python cProfile](references/python-cprofile.md) | Python cProfile |
74
| [Benchmarking](references/benchmarking.md) | Benchmarking |
75
| [Database Query Profiling](references/database-query-profiling.md) | Database Query Profiling |
76
| [Flame Graph Generation](references/flame-graph-generation.md) | Flame Graph Generation |
77
78
## Best Practices
79
80
### ✅ DO
81
82
- Profile before optimizing
83
- Focus on hot paths
84
- Measure impact of changes
85
- Use production-like data
86
- Consider memory vs speed tradeoffs
87
- Document optimization rationale
88
89
### ❌ DON'T
90
91
- Optimize without profiling
92
- Ignore readability for minor gains
93
- Skip benchmarking
94
- Optimize cold paths
95
- Make changes without measurement
96

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…