Skip to content

Commit 7712b23

Browse files
committed
docs(guides): some improvements to profiling doc
1 parent 874461e commit 7712b23

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

site/src/content/docs/guides/profiling.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CPU profiles are stored in `.modestbench/profiles/` to keep your workspace clean
3838
You can analyze existing profiles with the `--input` flag:
3939

4040
```bash
41-
modestbench analyze --input .modestbench/profiles/CPU.20231027.161625.89167.0.001.cpuprofile
41+
modestbench analyze --input .modestbench/profiles/CPU.bunchanumbers.cpuprofile
4242
```
4343

4444
## Understanding the Output
@@ -119,14 +119,14 @@ Output:
119119
```text
120120
██ Grouped by File
121121
122-
▓ src/utils/sorting.js 18.5% (1,523 ticks)
123-
▪ sortArray 12.3% (1,013 ticks) :42
124-
▪ quickSort 4.2% (346 ticks) :98
125-
▪ partition 2.0% (164 ticks) :125
122+
▓ src/utils/sorting.js 18.5% (1,523 ticks)
123+
▪ sortArray 12.3% (1,013 ticks) :42
124+
▪ quickSort 4.2% (346 ticks) :98
125+
▪ partition 2.0% (164 ticks) :125
126126
127-
▓ src/validators/schema.js 11.3% (931 ticks)
128-
▪ validateSchema 8.7% (716 ticks) :28
129-
▪ checkRequired 2.6% (215 ticks) :145
127+
▓ src/validators/schema.js 11.3% (931 ticks)
128+
▪ validateSchema 8.7% (716 ticks) :28
129+
▪ checkRequired 2.6% (215 ticks) :145
130130
```
131131

132132
This view is particularly useful for:
@@ -181,14 +181,16 @@ Functions with 5%+ execution time that are pure, frequently called, and algorith
181181

182182
### 3. Create Benchmarks
183183

184-
For each candidate, create a focused benchmark:
184+
First, initialize the benchmarking system if you haven't already:
185185

186186
```bash
187-
# Initialize if you haven't already
188187
modestbench init
188+
```
189+
190+
Now, for each candidate, create a focused benchmark:
189191

190-
# Create a benchmark file
191-
cat > benchmarks/sorting.bench.js << 'EOF'
192+
```javascript
193+
// benchmarks/sorting.bench.js
192194
import { sortArray } from '../src/utils/sorting.js';
193195

194196
const small = Array.from({ length: 100 }, () => Math.random());
@@ -206,7 +208,6 @@ export default {
206208
},
207209
},
208210
};
209-
EOF
210211
```
211212

212213
### 4. Run and Track
@@ -236,6 +237,11 @@ modestbench analyze "npm test"
236237
- High test execution time often indicates real performance issues
237238
- Easy to reproduce and measure
238239

240+
:::tip[Wanna Benchmark Tests?]
241+
242+
See the [Test Adapters](/guides/test-adapters/) guide for more information.
243+
:::
244+
239245
### Profiling Application Startup
240246

241247
Identify slow initialization code:
@@ -396,7 +402,7 @@ If the profiler shows 0 user functions:
396402

397403
### Profile Data is Stale
398404

399-
Profile logs are reused if they exist. To get fresh data:
405+
Profile logs are reused if they exist. To get fresh data, remove the `isolate-*.log` files created by Node.js's V8 profiler (via the `--cpu-prof` flag that `modestbench analyze` uses under the hood):
400406

401407
```bash
402408
# Remove old logs

0 commit comments

Comments
 (0)