39
39
await new Promise (r => setTimeout (r, 1 )) // we wait 1ms :)
40
40
console .log (' I am slower' )
41
41
})
42
+ .todo (' unimplemented bench' )
42
43
43
44
await bench .run ();
44
45
@@ -51,6 +52,19 @@ console.table(bench.table());
51
52
// │ 0 │ 'faster task' │ '41,621' │ 24025.791819761525 │ '±20.50%' │ 4257 │
52
53
// │ 1 │ 'slower task' │ '828' │ 1207382.7838323202 │ '±7.07%' │ 83 │
53
54
// └─────────┴───────────────┴──────────┴────────────────────┴───────────┴─────────┘
55
+
56
+ console .table (
57
+ bench .todos .map (({ name }) => ({
58
+ ' Task name' : name,
59
+ })),
60
+ );
61
+
62
+ // Output:
63
+ // ┌─────────┬───────────────────────┐
64
+ // │ (index) │ Task name │
65
+ // ├─────────┼───────────────────────┤
66
+ // │ 0 │ 'unimplemented bench' │
67
+ // └─────────┴───────────────────────┘
54
68
```
55
69
56
70
The ` add ` method accepts a task name and a task function, so it can benchmark
@@ -133,6 +147,8 @@ export type Hook = (task: Task, mode: "warmup" | "run") => void | Promise<void>;
133
147
- ` get results(): (TaskResult | undefined)[] ` : (getter) tasks results as an array
134
148
- ` get tasks(): Task[] ` : (getter) tasks as an array
135
149
- ` getTask(name: string): Task | undefined ` : get a task based on the name
150
+ - ` todo(name: string, fn?: Fn, opts: FnOptions) ` : add a benchmark todo to the todo map
151
+ - ` get todos(): Task[] ` : (getter) tasks todos as an array
136
152
137
153
### ` Task `
138
154
@@ -298,7 +314,8 @@ export type BenchEvents =
298
314
| " warmup" // when the benchmarks start getting warmed up (before start)
299
315
| " cycle" // when running each benchmark task gets done (cycle)
300
316
| " add" // when a Task gets added to the Bench
301
- | " remove" ; // when a Task gets removed of the Bench
317
+ | " remove" // when a Task gets removed of the Bench
318
+ | " todo" ; // when a todo Task gets added to the Bench
302
319
303
320
/**
304
321
* task events
0 commit comments