Skip to content

Commit

Permalink
update memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Sep 26, 2024
1 parent aa480bc commit 109ef90
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ Oxc is 4x faster than tsc on small files, and 10x faster on larger files.
4.43x faster than tsc
```

### Memory Usage

On `parser.ts` by using `/usr/bin/time -alh node`:

| | Max RSS |
| --- | ------- |
| oxc | 51 MB |
| swc | 67MB |
| babel | 172MB |

## Fixtures

* [TypeScript/src/compiler/parser.ts](https://github.com/microsoft/TypeScript/blob/3ad0f752482f5e846dc35a69572ccb43311826c0/src/compiler/parser.ts) - an atypical large file with 10777 lines.
Expand Down
10 changes: 10 additions & 0 deletions memory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

echo 'oxc'
/usr/bin/time -alh node ./src/memory/oxc.js

echo 'swc'
/usr/bin/time -alh node ./src/memory/swc.js

echo 'babel'
/usr/bin/time -alh node ./src/memory/babel.js
13 changes: 13 additions & 0 deletions src/memory/babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fs from "fs";
import { transformSync as babelTransform } from '@babel/core'
let filename = "./fixtures/parser.ts";
const sourceText = fs.readFileSync(filename, "utf8");
babelTransform(sourceText, {
filename,
babelrc: false,
comments: false,
presets: [
"@babel/preset-typescript",
["@babel/preset-react", { runtime: 'automatic' }],
]
});
5 changes: 5 additions & 0 deletions src/memory/oxc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import fs from "fs";
import { transform as oxcTransform } from "oxc-transform";
let filename = "./fixtures/parser.ts";
const sourceText = fs.readFileSync(filename, "utf8");
oxcTransform(filename, sourceText);
18 changes: 18 additions & 0 deletions src/memory/swc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fs from "fs";
import { transformSync as swcTransform } from "@swc/core";
let filename = "./fixtures/parser.ts";
const sourceText = fs.readFileSync(filename, "utf8");
swcTransform(sourceText, {
filename,
swcrc: false,
jsc: {
target: "esnext",
transform: {
treatConstEnumAsEnum: true,
react: {
runtime: 'automatic'
}
},
preserveAllComments: false,
}
});

0 comments on commit 109ef90

Please sign in to comment.