@effect-bench/core 0.0.1 → 0.0.2

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 (2) hide show
  1. package/README.md +18 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,20 +5,25 @@ Benchmarks for [Effect](https://effect.website) code, with JSON output and basel
5
5
  Community project, not affiliated with the Effect team.
6
6
 
7
7
  ```ts
8
- // bench/schema.bench.ts
8
+ // bench/user.bench.ts
9
9
  import { Bench } from '@effect-bench/core'
10
- import { Effect } from 'effect'
10
+ import { Effect, Schema } from 'effect'
11
11
 
12
- export default Bench.suite('workflowCompiler', { layer: NodeRegistry.layer })(
13
- Bench.params('compile', { nodes: [10, 100, 1000] }, {
14
- prepare: ({ nodes }) => Effect.succeed(makeDraft(nodes)), // untimed
15
- run: draft => compile(draft), // timed
16
- }),
12
+ const User = Schema.Struct({ id: Schema.Number, email: Schema.String, tags: Schema.Array(Schema.String) })
13
+ const user = { id: 1, email: 'ada@example.com', tags: ['admin'] }
14
+ const decodeSync = Schema.decodeUnknownSync(User)
15
+ const decodeEffect = Schema.decodeUnknownEffect(User)
16
+
17
+ export default Bench.suite('userSchema')(
17
18
  Bench.group('decode', { baseline: 'sync' })(
18
- Bench.sync('sync', () => decodeSync(lead)),
19
- Bench.make('effect', () => decodeEffect(lead)),
19
+ Bench.sync('sync', () => decodeSync(user)),
20
+ Bench.make('effect', () => decodeEffect(user)),
20
21
  ),
21
- Bench.sync('encode', () => encode(payload), { budget: { p99: '5 millis' } }),
22
+ Bench.params('stringify', { rows: [10, 1000] }, {
23
+ prepare: ({ rows }) => Effect.succeed(Array.from({ length: rows }, () => user)), // untimed
24
+ sync: users => JSON.stringify(users), // timed
25
+ budget: { p99: '5 millis' },
26
+ }),
22
27
  )
23
28
  ```
24
29
 
@@ -37,7 +42,7 @@ effect-bench run --rigorous --forks 8 # more processes for a tighter interval
37
42
  | `Bench.make(name, effect)` | re-runs one Effect value |
38
43
  | `Bench.make(name, ctx => effect)` | builds and runs a fresh Effect per operation |
39
44
  | `Bench.sync(name, ctx => value)` | a plain function |
40
- | `Bench.params(name, matrix, { prepare?, run \| sync })` | one bench per combination, ids like `compile[nodes=100]` |
45
+ | `Bench.params(name, matrix, { prepare?, run \| sync })` | one bench per combination, ids like `stringify[rows=1000]` |
41
46
  | `Bench.group(name, { baseline })(...)` | alternatives, reported as a ratio to the baseline |
42
47
 
43
48
  `Bench.suite(name, { layer, setup, ...options })` builds `layer` once per suite and runs `setup` in the suite's scope; its result is the `ctx` each bench receives. Benches can only use services the layer provides — anything else is a type error.
@@ -49,8 +54,8 @@ Options (suite or bench): `samples`, `minTime`, `warmup`, `memory` (GC + heap de
49
54
  `--json` prints one record per line on stdout: a `result` per bench and a final `summary`. Logs go to stderr.
50
55
 
51
56
  ```json
52
- {"type":"result","schemaVersion":1,"status":"ok","id":"leadSchema/decode/effect","stats":{"medianNs":858,"p99Ns":943,"opsPerSec":1165161,...},"comparison":{"baseline":"before","change":0.051,"ci":[0.039,0.058],"verdict":"slower","stale":false},"relative":{"baselineId":"leadSchema/decode/sync","ratio":5.1}}
53
- {"type":"summary","schemaVersion":1,"total":4,"failed":0,"regressions":1,"budgetsExceeded":0,"stale":0,"exitCode":1}
57
+ {"type":"result","schemaVersion":2,"status":"ok","id":"userSchema/decode/effect","stats":{"medianNs":858,"p99Ns":943,"opsPerSec":1165161,...},"comparison":{"baseline":"before","change":0.051,"ci":[0.039,0.058],"verdict":"slower","stale":false},"relative":{"baselineId":"userSchema/decode/sync","ratio":5.1}}
58
+ {"type":"summary","schemaVersion":2,"total":4,"failed":0,"regressions":1,"budgetsExceeded":0,"stale":0,"exitCode":1}
54
59
  ```
55
60
 
56
61
  ## How verdicts work
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-bench/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {