Commit 56a99d5
committed
refactor(oxfmt): simplify
`call_async` does the same thing as `call_with_return_value` + `channel`, so use `call_async` to simplify it and reduce some unnecessary overhead
### Benchmark
I benchmarked this PR locally, and the results indicate that it is 9% faster than before in the `Outline` repo.
EDIT: Maybe just a noise since `Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interference from other programs.` was displayed.
```shell
Setup complete! Run 'pnpm run bench' to start benchmarking.
=========================================
JavaScript/TypeScript Formatter Benchmark
=========================================
Formatters: Prettier, Biome, Oxfmt
Starting benchmark with:
- 3 warmup runs
- 10 benchmark runs
- Git reset before each run
=========================================
Benchmarking parser.ts (single large file)
=========================================
Benchmark 1: biome
Time (mean ± σ): 69.5 ms ± 0.9 ms [User: 55.4 ms, System: 9.7 ms]
Range (min … max): 68.3 ms … 71.2 ms 10 runs
Benchmark 2: oxfmt-new
Time (mean ± σ): 30.7 ms ± 0.3 ms [User: 23.7 ms, System: 11.0 ms]
Range (min … max): 30.3 ms … 31.3 ms 10 runs
Benchmark 3: oxfmt-old
Time (mean ± σ): 30.4 ms ± 0.3 ms [User: 23.6 ms, System: 10.6 ms]
Range (min … max): 30.1 ms … 30.9 ms 10 runs
Summary
oxfmt-old ran
1.01 ± 0.01 times faster than oxfmt-new
2.29 ± 0.04 times faster than biome
=========================================
Benchmarking Outline repository
=========================================
Benchmark 1: biome
Time (mean ± σ): 154.6 ms ± 6.0 ms [User: 825.2 ms, System: 555.8 ms]
Range (min … max): 147.5 ms … 164.0 ms 10 runs
Benchmark 2: oxfmt-new
Time (mean ± σ): 65.8 ms ± 2.3 ms [User: 196.0 ms, System: 265.3 ms]
Range (min … max): 60.7 ms … 68.8 ms 10 runs
Benchmark 3: oxfmt-old
Time (mean ± σ): 72.0 ms ± 17.7 ms [User: 195.0 ms, System: 277.3 ms]
Range (min … max): 62.6 ms … 121.1 ms 10 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs.
Summary
oxfmt-new ran
1.09 ± 0.27 times faster than oxfmt-old
2.35 ± 0.12 times faster than biome
```wrap_format_embeded (#15798)1 parent 4fe3aac commit 56a99d5
1 file changed
+15
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | 54 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
89 | 68 | | |
90 | | - | |
| 69 | + | |
91 | 70 | | |
92 | 71 | | |
93 | 72 | | |
| |||
0 commit comments