Skip to content

Commit

Permalink
CHG: README clarification. Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Llorx committed Aug 20, 2023
1 parent 6f60cc1 commit eeba2e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,21 @@ Creates a new `IsoBench` instance to benchmark your code.

---
```typescript
bench.add<T>(name:string, test:(setupReturn?:T)=>void, setup?:()=>T):this;
bench.add(name:string, test:()=>void):this;
```
Adds new test.
- `name`: The name of this test.
- `test`: The test function to run.
Returns the IsoBench instance, to concatenate new tests easily.

---
```typescript
bench.add<T>(name:string, test:(setupReturn:T)=>void, setup:()=>T):this;
```
Adds new test.
- `name`: The name of this test.
- `test`: The test function to run.
- `setup`: The setup function to run before the test.
If you are very concerned about the pollution between tests when preparing data that only one test needs, you can use the `setup` callback to return the data that will be provided to the `test` callback as the first argument. The other tests will not run this `setup` callback in their isolated processes. Example:
```typescript
bench.add("object.result", (obj) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iso-bench",
"version": "2.4.0",
"version": "2.4.1",
"description": "Small benchmark library focused in avoiding optimization/deoptimization pollution between tests by isolating them.",
"types": "./lib/_types/index.d.ts",
"main": "./lib/",
Expand Down

0 comments on commit eeba2e2

Please sign in to comment.