Skip to content

Commit

Permalink
docs: use table to show perf results
Browse files Browse the repository at this point in the history
  • Loading branch information
acutmore committed Aug 21, 2024
1 parent 363efad commit 0de8d8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class C extends Array {
The benefits of this library are:

- It is fast
- Only 50% slower than a native transformer in a micro-benchmark (see `./perf` folder)
- Only 50% slower than a native transformer in a micro-benchmark (see [`./perf`](./perf/) folder)
- No new JavaScript code is generated, instead it re-uses slices of the existing source string
- This is particularly true if other parts of your program are already generating the TypeScript SourceFile object for other reasons because it can [be reused](#bring-your-own-ast), and producing the AST is the most time consuming part.
- 100% JavaScript runtime
Expand Down
26 changes: 14 additions & 12 deletions perf/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `ts-blank-space` performance tests

Transforming just over 500,000 lines of TypeScript (one 50k file, ten times).
Transforming just over 500,000 lines of TypeScript (one ~50k file, ten times).

## Setup

Expand All @@ -21,17 +21,19 @@ You will also need to install https://github.com/sharkdp/hyperfine

- Node.js v20.11.1
- Apple M2 Pro 32GB

```sh
Summary
node ./swc-native-async.js ./fixtures/checker.txt 10 ran
1.52 ± 0.05 times faster than node ./ts-blank-space.js ./fixtures/checker.txt 10
1.71 ± 0.03 times faster than node ./swc-wasm-strip.js ./fixtures/checker.txt 10
1.85 ± 0.05 times faster than node ./sucrase.js ./fixtures/checker.txt 10
3.19 ± 0.05 times faster than node ./swc-native-sync.js ./fixtures/checker.txt 10
4.98 ± 0.08 times faster than node ./swc-wasm.js ./fixtures/checker.txt 10
7.58 ± 0.16 times faster than node ./typescript.js ./fixtures/checker.txt 10
```
- 1 File read done in Node.js
- 3 warmup runs
- 10 measured runs

| package | runtime | mean time ± σ |
| -------------------- | ------------ | ------------------ |
| @swc/core | async native | 853.7 ms ± 11.8 ms |
| ts-blank-space | sync JS | 1.295 s ± 0.035 s |
| @swc/wasm-typescript | sync wasm | 1.462 s ± 0.013 s |
| sucrase | sync JS | 1.583 s ± 0.041 s |
| @swc/core | sync native | 2.727 s ± 0.020 s |
| @swc/wasm | sync wasm | 4.252 s ± 0.027 s |
| typescript | sync JS | 6.470 s ± 0.109 s |

```sh
Benchmark: node ./swc-native-async.js ./fixtures/checker.txt 10
Expand Down

0 comments on commit 0de8d8e

Please sign in to comment.