overtake 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +49 -31
  2. package/context7.json +4 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -112,10 +112,12 @@ benchmark('local', () => 1)
112
112
 
113
113
  // Programmatic usage – provide baseUrl
114
114
  const suite = new Benchmark('local');
115
- suite.target('helper', async () => {
116
- const { helper } = await import('./helpers.js');
117
- return { helper };
118
- });
115
+ suite
116
+ .target('helper', async () => {
117
+ const { helper } = await import('./helpers.js');
118
+ return { helper };
119
+ })
120
+ .measure('use helper', ({ helper }) => helper());
119
121
  await suite.execute({ baseUrl: import.meta.url });
120
122
  ```
121
123
 
@@ -127,16 +129,15 @@ When using `npx overtake`, a global `benchmark` function is provided:
127
129
 
128
130
  ```typescript
129
131
  // benchmark.ts - No imports needed!
130
- benchmark('small', () => generateSmallData())
131
- .feed('large', () => generateLargeData())
132
- .target('algorithm A')
133
- .measure('process', (_, input) => {
134
- processA(input);
135
- })
136
- .target('algorithm B')
137
- .measure('process', (_, input) => {
138
- processB(input);
139
- });
132
+ const suite = benchmark('small', () => generateSmallData()).feed('large', () => generateLargeData());
133
+
134
+ suite.target('algorithm A').measure('process', (_, input) => {
135
+ processA(input);
136
+ });
137
+
138
+ suite.target('algorithm B').measure('process', (_, input) => {
139
+ processB(input);
140
+ });
140
141
  ```
141
142
 
142
143
  ```bash
@@ -171,21 +172,32 @@ printTableReports(reports);
171
172
 
172
173
  ```typescript
173
174
  // Create with initial feed
174
- benchmark('initial data', () => data)
175
- .feed('more data', () => moreData) // Add more datasets
175
+ const suite = benchmark('initial data', () => data).feed('more data', () => moreData); // Add more datasets
176
176
 
177
- // Define what to compare
178
- .target('implementation A')
179
- .measure('operation', (ctx, input) => {
180
- /* ... */
181
- })
177
+ // Define what to compare
178
+ suite.target('implementation A').measure('operation', (ctx, input) => {
179
+ /* ... */
180
+ });
182
181
 
183
- .target('implementation B')
184
- .measure('operation', (ctx, input) => {
185
- /* ... */
186
- });
182
+ suite.target('implementation B').measure('operation', (ctx, input) => {
183
+ /* ... */
184
+ });
187
185
  ```
188
186
 
187
+ ### Method Chaining Reference
188
+
189
+ ```
190
+ benchmark(name, feedFn) -> Benchmark
191
+ .feed(name, feedFn) -> Benchmark
192
+ .target(name, setup?) -> Target
193
+ .teardown(fn) -> Target
194
+ .measure(name, fn) -> Measure
195
+ .pre(fn) -> Measure
196
+ .post(fn) -> Measure
197
+ ```
198
+
199
+ Note: `.measure()` returns `Measure`, not `Benchmark`. To add multiple targets, call `suite.target()` separately for each.
200
+
189
201
  ### Targets with Setup
190
202
 
191
203
  ```typescript
@@ -243,12 +255,18 @@ sumBenchmark.target('reduce').measure('sum', (_, numbers) => {
243
255
 
244
256
  ```typescript
245
257
  // examples/imports.ts - Correct way to import local files
246
- .target('local files', async () => {
247
- const { join } = await import('node:path');
248
- const modulePath = join(process.cwd(), './build/myModule.js');
249
- const { myFunction } = await import(modulePath);
250
- return { myFunction };
251
- })
258
+ const suite = benchmark('local modules', () => testData);
259
+
260
+ suite
261
+ .target('local files', async () => {
262
+ const { join } = await import('node:path');
263
+ const modulePath = join(process.cwd(), './build/myModule.js');
264
+ const { myFunction } = await import(modulePath);
265
+ return { myFunction };
266
+ })
267
+ .measure('call function', ({ myFunction }, input) => {
268
+ myFunction(input);
269
+ });
252
270
  ```
253
271
 
254
272
  **[📁 See all examples](./examples/):**
package/context7.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "url": "https://context7.com/3axap4ehko/overtake",
3
+ "public_key": "pk_cWMMIaGchuWIje6ayobfY"
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overtake",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "NodeJS performance benchmark",
5
5
  "type": "module",
6
6
  "types": "build/index.d.ts",