Add typescript benchmark#19
Conversation
RafaelGSS
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Could you please check if dead-code elimination isn't in place?
You can do it by:
./bench-it node baseline- Assign
ts.*return to a variable and thenassert.ok(var) ./bench-it node
and compare if the results are drastically different. I can do it tonight if you aren't available to do so :)
|
If I undestood correctly: Baseline: ./bench-it.js $(which node) baseline
7e25625544dc7437012c5d5afa08e282b53cefd2
Running Node.js Package Benchmark...
--------------------------------------------
typescript
transpile: 85.48 (10 samples)
createSourceFile: 2.715K (272 samples)
getSemanticDiagnostics: 3.241 (10 samples)
did this changes: diff --git a/src/typescript-benchmark.js b/src/typescript-benchmark.js
index cb7095a..85d06e5 100644
--- a/src/typescript-benchmark.js
+++ b/src/typescript-benchmark.js
@@ -1,6 +1,7 @@
const fs = require("node:fs");
const ts = require("typescript");
const path = require("node:path");
+const assert = require("node:assert");
const filePath = path.join(__dirname, "..", "fixtures", "ts-sample.ts");
const code = fs.readFileSync(filePath, "utf8");
@@ -12,7 +13,7 @@ module.exports = {
{
name: "transpile",
fn: () => {
- ts.transpile(
+ const transpiled = ts.transpile(
code,
{
// CJS Settings
@@ -32,18 +33,22 @@ module.exports = {
},
filePath,
);
+
+ assert.ok(transpiled)
},
},
{
name: "createSourceFile",
fn: () => {
- ts.createSourceFile(
+ const source = ts.createSourceFile(
filePath,
code,
ts.ScriptTarget.ESNext,
false,
ts.ScriptKind.TS,
);
+
+ assert.ok(source)
},
},
{
@@ -74,7 +79,9 @@ module.exports = {
},
});
- program.getSemanticDiagnostics(program.getSourceFile(filePath));
+ const diagnostics = program.getSemanticDiagnostics(program.getSourceFile(filePath));
+
+ assert.ok(diagnostics.length === 0);
},
},
],./bench-it.js $(which node)
Running Node.js Package Benchmark...
--------------------------------------------
typescript
transpile: 76.11 (10 samples)
createSourceFile: 2.61K (261 samples)
getSemanticDiagnostics: 3.102 (10 samples)I don't think dead code elimination is in place... Should be that way, right? |
|
I've also added another commit improving how the output is printed in TTY mode. Previously it collected all results and then printed it out, now it whenever a new result comes, it gets printed out. It helps by giving feedback on what run it is currently, how many were already finished and how many are waiting to be ran. Also added machine info in TTY mode, which gives some basic informations when mentally comparing results across machines/node versions. However feel free to revert it if you don't like the result. |
|
Thanks! |
closes #15
This PR adds 3 typescript benchmarks.
Output sample: