Automated summary
Lays out a systematic profiling workflow: define the metric, establish a baseline, find the bottleneck, apply one fix, then confirm the gain with statistical rigor.
Strengths
- Requires a measured baseline (5+ runs, median and p95) before any optimization
- Explains how to read a flame chart using self time and the critical path
- Ships a concrete Lighthouse CI config for enforcing performance budgets
- Clearly separates lab data (Lighthouse) from field data (CrUX/RUM)
Limitations
- Strongly web-oriented (Lighthouse, CrUX, LCP/INP) and not directly portable to native or backend profiling
- The statistical validation step is only sketched — no specific test or threshold is given
- Assumes a stable measurement environment, which is hard to guarantee on a laptop
Use it when slowness is felt but unmeasured, or before starting any optimization so you can prove the change actually helped.
Avoid it as a guide to native profiler tooling (perf, pprof, Instruments), which it does not cover.
Security analysis
SafeThe skill is a pure methodology document about performance profiling. The only executable content is benign, illustrative CI/Lighthouse commands and a statistics helper function; there is no destructive command, no credential or token handling, no network exfiltration, no obfuscated payload, and no attempt to disable safety controls. Worst-case risk is incidental npm package execution, which is standard for frontend profiling work.
- •Includes shell snippets that invoke `npx lighthouse` against a URL, which downloads and executes a package from npm at run time (normal, expected tooling, but a supply-chain consideration worth noting)
- •No declared allowed-tools, so an agent may assume broad shell access to run the example commands
Examples
Our checkout page feels slow but nobody has measured it. Set up a proper baseline first and tell me what is actually slow before we change any code.I attached a Chrome DevTools Performance trace of our dashboard. Walk me through the flame chart and tell me which function we should optimize first, and why.Add Lighthouse CI performance budgets to our GitHub Actions pipeline — LCP under 2.5s, CLS under 0.1, total byte weight under 200KB — and fail the build when they regress.Profiling Methodology
Apply a systematic, measurement-first profiling workflow — define metric, establish baseline, identify bottleneck, implement fix, verify improvement with statistical significance — to avoid wasted optimization effort and ensure every change demonstrably improves performance.
When to Use
- Performance is perceived as slow but no one has measured what is actually slow
- You need to establish a baseline before optimizing to prove the optimization worked
- A flame chart or performance trace needs to be read and interpreted
- Performance budgets need to be defined and enforced in CI
- Lab data (Lighthouse) and field data (CrUX/RUM) disagree and you need to understand why
- You are deciding between synthetic monitoring and Real User Monitoring
- A performance regression needs to be detected and attributed to a specific commit
- Single-run measurements are producing inconsistent results and statistical rigor is needed
- Micro-benchmarking in isolation is misleading and end-to-end measurement is needed
- The team is about to "optimize" without a clear bottleneck and you need to redirect effort
Instructions
-
Never optimize without a baseline. Before changing any code, measure the current state with the exact metric you want to improve. Record at least 5 measurements to establish a stable baseline (performance varies 10-30% between runs):
# Example: run Lighthouse 5 times and compute median for i in {1..5}; do npx lighthouse https://example.com --output=json --output-path=./run-$i.json --quiet done # Extract LCP from each run and compute median -
Follow the profiling workflow:
- Define the metric — what exactly are you measuring? (LCP, INP, bundle size, API p95 latency)
- Establish baseline — measure 5+ runs, compute median and p95, record the values
- Identify bottleneck — use DevTools Performance panel, flame chart, or profiler to find the slowest part
- Hypothesize cause — formulate a specific theory ("style recalculation during scroll takes 40ms because of descendant selectors on body")
- Implement fix — make exactly one change
- Measure again — same conditions, 5+ runs
- Validate significance — is the improvement larger than the natural variance? Use a statistical test if the effect is small
-
Read flame charts effectively. In Chrome DevTools Performance panel:
- Width = time duration (wider = longer)
- Depth = call stack depth (deeper = more nested function calls)
- Self time = time spent in the function itself (not in its callees)
- Total time = self time + all callee time
The optimization target is the function with the largest self time that is on the critical path. Deep call stacks with small self times are not the bottleneck — the leaf functions are.
-
Use CPU throttling in DevTools. Developer hardware is 5-10x faster than the median user device. Always profile with:
- CPU throttling: 4x slowdown (simulates mid-tier mobile)
- Network throttling: "Fast 3G" or "Slow 4G"
- This reveals bottlenecks that are invisible on high-end hardware
-
Set performance budgets and enforce in CI:
// lighthouserc.js — Lighthouse CI configuration module.exports = { ci: { assert: { assertions: { 'largest-contentful-paint': ['error', { maxNumericValue: 2500 }], interactive: ['error', { maxNumericValue: 3500 }], 'total-byte-weight': ['error', { maxNumericValue: 200000 }], 'cumulative-layout-shift': ['error', { maxNumericValue: 0.1 }], }, }, }, }; -
Understand lab vs field data:
| Aspect | Lab (Lighthouse, WebPageTest) | Field (CrUX, RUM) | | ---------- | ------------------------------------ | ----------------------------------- | | Conditions | Controlled, reproducible | Real user devices and networks | | Device | Specified throttling | Actual user hardware | | Coverage | Single page, one scenario | All pages, all users | | Use for | Debugging, regression detection | Understanding real user experience | | Limitation | Does not reflect real-world variance | Cannot reproduce specific scenarios |
Lab and field data should agree directionally. If Lighthouse shows LCP of 1.5s but CrUX shows 4.0s, the lab test is not representative of real user conditions (likely missing slow devices or slow networks).
-
Measure with statistical significance:
// Simple statistical validation for A/B performance tests function isSignificant(controlSamples, treatmentSamples, confidenceLevel = 0.95) { const controlMean = mean(controlSamples); const treatmentMean = mean(treatmentSamples); const controlStdDev = stddev(controlSamples); const treatmentStdDev = stddev(treatmentSamples); const n = controlSamples.length; const pooledStdErr = Math.sqrt((controlStdDev ** 2 + treatmentStdDev ** 2) / n); const tStat = (controlMean - treatmentMean) / pooledStdErr; const criticalValue = 1.96; // for 95% confidence return Math.abs(tStat) > criticalValue; }
Details
The Profiling Pyramid
Optimize in this order (each level has 10x the impact of the one below):
- Architecture — SSR vs CSR, code splitting, caching strategy (impact: seconds)
- Network — CDN, compression, HTTP/2, image optimization (impact: hundreds of ms)
- Rendering — critical CSS, defer/async, layout containment (impact: tens of ms)
- Code — algorithm optimization, micro-optimization (impact: single ms)
Most wasted optimization effort happens when teams optimize at level 4 (micro-optimizing a function from 2ms to 1ms) while the architecture at level 1 adds 3 seconds of unnecessary latency.
Worked Example: Pinterest A/B Testing Protocol
Pinterest's performance team validates every optimization with an A/B test:
- The optimization is deployed to 1% of traffic
- Both control (original) and treatment (optimized) groups are monitored for 7 days
- Key metrics: LCP p50/p75/p95, INP p50/p75/p95, engagement rate, bounce rate
- Statistical significance test at p<0.05 is required before promotion
- Results are reviewed for selection bias (are the 1% representative?)
This protocol caught a "30% LCP improvement" that was actually a 2% improvement. The initial benchmark ran on a fast internal network; the A/B test revealed the improvement was much smaller for real users on cellular networks. The fix was still shipped because 2% improvement for all users was valuable, but expectations were correctly calibrated.
Worked Example: Shopify Lighthouse CI
Shopify runs Lighthouse CI on every PR for every storefront route. Each route has a performance budget:
- Homepage: LCP < 2.0s, bundle < 150KB
- Product page: LCP < 2.5s, bundle < 200KB
- Cart page: INP < 150ms, CLS < 0.05
Any PR that regresses a metric beyond its budget fails the build. The PR author receives a comparison report showing exactly which metric regressed, by how much, and which files contributed to the regression (via source map analysis).
Regression Detection Strategy
Use a three-tier approach:
- CI gate (per-PR) — Lighthouse CI with per-route budgets. Catches large regressions before merge.
- Synthetic monitoring (continuous) — Run Lighthouse or WebPageTest hourly on production. Alerts when metrics deviate >10% from 7-day rolling average.
- RUM alerting (field) — Monitor CrUX or custom RUM data. Alert when p75 metrics cross thresholds (LCP > 2.5s, INP > 200ms, CLS > 0.1).
Anti-Patterns
Optimizing without measuring first. "I bet the problem is the database" leads to weeks of database optimization when the real bottleneck is a 3MB uncompressed hero image. Always profile first, then optimize the actual bottleneck.
Testing on developer hardware without throttling. A MacBook Pro on gigabit fiber does not represent the median user on a mid-tier Android phone on 4G. Always enable CPU throttling (4x) and network throttling (Fast 3G) in DevTools, or use WebPageTest with a real Moto G4 device.
Single-run measurements. Performance varies 10-30% between runs due to background processes, network conditions, and GC timing. A single run showing 2.1s LCP could be 2.7s on the next run. Always take the median of 5+ runs.
Optimizing p50 when p95 is the real problem. Median latency looks great at 500ms, but p95 is 8 seconds. Tail latencies affect 5% of users on every page load. Focus on percentile metrics, not averages.
Micro-benchmarking in isolation. Optimizing a function from 1ms to 0.1ms is a 10x improvement that is completely irrelevant if the function is called once during a 3-second page load. Always measure the impact on the end-to-end metric, not the isolated function.
Premature optimization without profiling. Adding useMemo to every React component, will-change to every element, or code-splitting every route "just in case" adds complexity without measured benefit. Profile first, optimize only the measured bottleneck.
Source
- Google Lighthouse documentation — https://developer.chrome.com/docs/lighthouse
- WebPageTest documentation — https://docs.webpagetest.org/
- Chrome DevTools Performance panel guide — https://developer.chrome.com/docs/devtools/performance
- Brendan Gregg, "Systems Performance" methodology — https://www.brendangregg.com/methodology.html
- "How We Made the Web Faster" (Google)
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.
- Every optimization has a measured baseline, a measured result, and statistical validation.
- Performance budgets are defined and enforced in CI.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/profiling-methodology-ms9wnyln/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/profiling-methodology-ms9wnyln' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/profiling-methodology-ms9wnyln/download' --output '.skill-downloads/profiling-methodology-ms9wnyln/SKILL.md.part' && mv '.skill-downloads/profiling-methodology-ms9wnyln/SKILL.md.part' '.skill-downloads/profiling-methodology-ms9wnyln/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.
Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/profiling-methodology-ms9wnyln/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.